已重命名2个文件
已修改13个文件
已添加21个文件
| | |
| | | @TableField("bulk_weight") |
| | | private Double bulkWeight; |
| | | |
| | | @Column(name = "length", columnDefinition = "decimal(20,2) COMMENT 'é¿/ç´å¾(åä½ï¼ç±³)'") |
| | | @TableField("length") |
| | | private Double length = 0.0; |
| | | |
| | | @Column(name = "width", columnDefinition = "decimal(20,2) COMMENT '宽(åä½ï¼ç±³)'") |
| | | @TableField("width") |
| | | private Double width = 0.0; |
| | | |
| | | @Column(name = "height", columnDefinition = "decimal(20,2) COMMENT 'é«åº¦(åä½ï¼ç±³)'") |
| | | @TableField("height") |
| | | private Double height = 0.0; |
| | | |
| | | @Column(name = "store_keeper", columnDefinition = "varchar(40) COMMENT 'ä¿ç®¡å'") |
| | | @TableField("store_keeper") |
| | | private String storeKeeper; |
| | |
| | | @TableField("is_only_th") |
| | | private String isOnlyTH = Constant.YN_N; |
| | | |
| | | @Column(name = "diameter", columnDefinition = "decimal(20,2) COMMENT 'çä»ç´å¾(åä½ï¼ç±³)'") |
| | | @TableField("diameter") |
| | | private Double diameter = 0.0; |
| | | |
| | | @Column(name = "height", columnDefinition = "decimal(20,2) COMMENT 'çä»é«åº¦(åä½ï¼ç±³)'") |
| | | @TableField("height") |
| | | private Double height = 0.0; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.fzzy.igds.domain; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import javax.persistence.Column; |
| | | import javax.persistence.Entity; |
| | | import javax.persistence.Id; |
| | | import javax.persistence.Table; |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * @Description |
| | | * @Author CZT |
| | | * @Date 2026/01/09 11:55 |
| | | */ |
| | | @Data |
| | | @Entity |
| | | @Table(name = "d_weather_city") |
| | | @TableName("d_weather_city") |
| | | @EqualsAndHashCode(callSuper = false) |
| | | public class WeatherCity extends BizBaseEntity implements Serializable { |
| | | |
| | | /** |
| | | * |
| | | */ |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @Id |
| | | @Column(name = "id", columnDefinition = "varchar(40) COMMENT '主é®'") |
| | | @TableField("id") |
| | | private String id; |
| | | |
| | | @Column(name = "city_en", columnDefinition = "varchar(40) COMMENT 'åå¸ç¼ç '") |
| | | @TableField("city_en") |
| | | private String cityEn; |
| | | |
| | | @Column(name = "city_zh", columnDefinition = "varchar(40) COMMENT 'åå¸åç§°'") |
| | | @TableField("city_zh") |
| | | private String cityZh; |
| | | |
| | | @Column(name = "province_en", columnDefinition = "varchar(40) COMMENT 'ç份ç¼ç '") |
| | | @TableField("province_en") |
| | | private String provinceEn; |
| | | |
| | | @Column(name = "province_zh", columnDefinition = "varchar(40) COMMENT 'ç份åç§°'") |
| | | @TableField("province_zh") |
| | | private String provinceZh; |
| | | |
| | | @Column(name = "lat", columnDefinition = "varchar(40) COMMENT 'åæ '") |
| | | @TableField("lat") |
| | | private String lat; |
| | | |
| | | @Column(name = "lon", columnDefinition = "varchar(40) COMMENT 'åæ '") |
| | | @TableField("lon") |
| | | private String lon; |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.fzzy.igds.domain; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.fzzy.igds.constant.Constant; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import javax.persistence.Column; |
| | | import javax.persistence.Entity; |
| | | import javax.persistence.Id; |
| | | import javax.persistence.Table; |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * @Description |
| | | * @Author CZT |
| | | * @Date 2026/01/09 11:55 |
| | | */ |
| | | @Data |
| | | @Entity |
| | | @Table(name = "d_weather_conf") |
| | | @TableName("d_weather_conf") |
| | | @EqualsAndHashCode(callSuper = false) |
| | | public class WeatherConf extends BizBaseEntity implements Serializable { |
| | | /** |
| | | * |
| | | */ |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @Id |
| | | @Column(name = "id", columnDefinition = "varchar(40) COMMENT '主é®'") |
| | | @TableField("id") |
| | | private String id; |
| | | |
| | | @Column(name = "dept_id", columnDefinition = "varchar(40) COMMENT 'æå±åºåº'") |
| | | @TableField("dept_id") |
| | | private String deptId; |
| | | |
| | | @Column(name = "name", columnDefinition = "varchar(40) COMMENT '设å¤åç§°'") |
| | | @TableField("name") |
| | | private String name; |
| | | |
| | | @Column(name = "ip", columnDefinition = "varchar(40) COMMENT 'IPå°å'") |
| | | @TableField("ip") |
| | | private String ip; |
| | | |
| | | @Column(name = "port", columnDefinition = "int COMMENT '端å£å·'") |
| | | @TableField("port") |
| | | private Integer port; |
| | | |
| | | @Column(name = "mac_status", columnDefinition = "varchar(40) COMMENT '设å¤ç¶æ'") |
| | | @TableField("mac_status") |
| | | private String macStatus = Constant.STATUS_NONE; |
| | | |
| | | @Column(name = "protocol", columnDefinition = "varchar(40) COMMENT 'æå±åè®®'") |
| | | @TableField("protocol") |
| | | private String protocol; |
| | | |
| | | @Column(name = "wan_tag", columnDefinition = "varchar(40) COMMENT 'å¤ç½æ°è±¡'") |
| | | @TableField("wan_tag") |
| | | private String wanTag = Constant.YN_N; |
| | | |
| | | @Column(name = "city", columnDefinition = "varchar(40) COMMENT 'æ°è±¡åå¸'") |
| | | @TableField("city") |
| | | private String city; |
| | | |
| | | @Column(name = "city_id", columnDefinition = "varchar(40) COMMENT 'æ°è±¡åå¸'") |
| | | @TableField("city_id") |
| | | private String cityId; |
| | | |
| | | @Column(name = "account", columnDefinition = "varchar(40) COMMENT 'è´¦å·'") |
| | | @TableField("account") |
| | | private String account; |
| | | |
| | | @Column(name = "password", columnDefinition = "varchar(40) COMMENT 'å¯ç '") |
| | | @TableField("password") |
| | | private String password; |
| | | |
| | | public WeatherConf() { |
| | | super(); |
| | | } |
| | | |
| | | public WeatherConf(String deptId) { |
| | | super(); |
| | | this.deptId = deptId; |
| | | } |
| | | |
| | | public WeatherConf(String deptId, String cityId) { |
| | | super(); |
| | | this.deptId = deptId; |
| | | this.cityId = cityId; |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.fzzy.igds.domain; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import javax.persistence.*; |
| | | import java.io.Serializable; |
| | | |
| | | |
| | | /** |
| | | * @Description æ°è±¡ä¿¡æ¯ï¼æ°è±¡ä¿¡æ¯æ¥æºå
æ¬å¤ç½ååºåºæ°è±¡ç«ï¼å½åå®ä¹å³ä½ä¸ºDATAåä½ä¸ºDTO使ç¨å æ¤ä¼å®ä¹èæçæ©å±å段 |
| | | * @Author CZT |
| | | * @Date 2026/01/09 11:55 |
| | | */ |
| | | @Data |
| | | @Entity |
| | | @Table(name = "d_weather_info") |
| | | @TableName("d_weather_info") |
| | | @EqualsAndHashCode(callSuper = false) |
| | | public class WeatherInfo extends BizBaseEntity implements Serializable { |
| | | |
| | | /** |
| | | * |
| | | */ |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @Id |
| | | @Column(name = "id", columnDefinition = "varchar(40) COMMENT '主é®'") |
| | | @TableField("id") |
| | | private String id; |
| | | |
| | | @Column(name = "dept_id", columnDefinition = "varchar(40) COMMENT 'æå±åºåº'") |
| | | @TableField("dept_id") |
| | | private String deptId; |
| | | |
| | | @Column(name = "city", columnDefinition = "varchar(40) COMMENT 'æå±åå¸'") |
| | | @TableField("city") |
| | | private String city; |
| | | |
| | | @Column(name = "temp", columnDefinition = "varchar(40) COMMENT '温度'") |
| | | @TableField("temp") |
| | | private String temp = "0.0â"; |
| | | |
| | | @Column(name = "humidity", columnDefinition = "varchar(40) COMMENT '湿度'") |
| | | @TableField("humidity") |
| | | private String humidity = "0.0%"; |
| | | |
| | | @Column(name = "wind_speed", columnDefinition = "varchar(40) COMMENT 'é£çº§'") |
| | | @TableField("wind_speed") |
| | | private String windSpeed = "0级"; |
| | | |
| | | @Column(name = "wind_meter", columnDefinition = "varchar(40) COMMENT 'é£é'") |
| | | @TableField("wind_meter") |
| | | private String windMeter = "0km/h"; |
| | | |
| | | @Column(name = "wind_direction", columnDefinition = "varchar(40) COMMENT 'é£å'") |
| | | @TableField("wind_direction") |
| | | private String windDirection = "æ é£"; |
| | | |
| | | @Column(name = "weather", columnDefinition = "varchar(40) COMMENT '天æ°'") |
| | | @TableField("weather") |
| | | private String weather = "æ´å¤©"; |
| | | |
| | | @Column(name = "rainfall", columnDefinition = "varchar(40) COMMENT 'é¨é'") |
| | | @TableField("rainfall") |
| | | private String rainfall = "0.0mm/h"; |
| | | |
| | | @Column(name = "pm25", columnDefinition = "varchar(40) COMMENT 'PM2.5'") |
| | | @TableField("pm25") |
| | | private String pm25 = "0μg/m3"; |
| | | |
| | | @Column(name = "air_level", columnDefinition = "varchar(40) COMMENT '空æ°è´¨éç级'") |
| | | @TableField("air_level") |
| | | private String airLevel = "ä¼"; |
| | | |
| | | @Column(name = "pressure", columnDefinition = "varchar(40) COMMENT '大æ°å'") |
| | | @TableField("pressure") |
| | | private String pressure; |
| | | |
| | | @Column(name = "source", columnDefinition = "varchar(40) COMMENT 'ä¿¡æ¯æ¥æº:01-åºåºæ°è±¡ç«ï¼02-å¤ç½'") |
| | | @TableField("source") |
| | | private String source = "01"; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.fzzy.igds.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.fzzy.igds.domain.WeatherCity; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | /** |
| | | * @Description |
| | | * @Author CZT |
| | | * @Date 2026/01/09 11:55 |
| | | */ |
| | | @Mapper |
| | | public interface WeatherCityMapper extends BaseMapper<WeatherCity> { |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.fzzy.igds.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.fzzy.igds.domain.WeatherConf; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | /** |
| | | * @Description |
| | | * @Author CZT |
| | | * @Date 2026/01/09 11:55 |
| | | */ |
| | | @Mapper |
| | | public interface WeatherConfMapper extends BaseMapper<WeatherConf> { |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.fzzy.igds.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.fzzy.igds.domain.WeatherInfo; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | /** |
| | | * @Description |
| | | * @Author CZT |
| | | * @Date 2026/01/09 11:55 |
| | | */ |
| | | @Mapper |
| | | public interface WeatherInfoMapper extends BaseMapper<WeatherInfo> { |
| | | } |
| | |
| | | |
| | | //æä»¶å
¨è·¯å¾ |
| | | String filePath = getFileSavePath(pathTag) + data.getFileName(); |
| | | |
| | | filePath = filePath.replace(FrameworkConfig.getProfile(), "/profile/"); |
| | | data.setFilePath(filePath); |
| | | |
| | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.fzzy.igds.constant.OrderRespEnum; |
| | | import com.fzzy.igds.constant.RedisConst; |
| | | import com.fzzy.igds.data.GrainData; |
| | | import com.fzzy.igds.data.GrainParam; |
| | | import com.fzzy.igds.data.InoutParam; |
| | | import com.fzzy.igds.domain.Depot; |
| | | import com.fzzy.igds.domain.Grain; |
| | | import com.fzzy.igds.domain.InoutRecord; |
| | | import com.fzzy.igds.mapper.GrainMapper; |
| | | import com.fzzy.igds.utils.ContextUtil; |
| | | import com.fzzy.igds.utils.DateUtil; |
| | | import com.fzzy.igds.websocket.WebSocketPacket; |
| | | import com.fzzy.igds.websocket.WebSocketServer; |
| | | import com.ruoyi.common.core.redis.RedisCache; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.time.DateFormatUtils; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.stereotype.Service; |
| | | import javax.annotation.Resource; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * @Description |
| | |
| | | |
| | | @Resource |
| | | private GrainMapper grainMapper; |
| | | @Resource |
| | | private RedisCache redisCache; |
| | | @Resource |
| | | private DepotService depotService; |
| | | |
| | | /** |
| | | * æ¥è¯¢æ°æ® |
| | |
| | | grainMapper.selectPage(page, queryWrapper); |
| | | } |
| | | |
| | | /** |
| | | * JPA - æ´æ°æ°æ® |
| | | * @param data |
| | | */ |
| | | public void saveOrUpdateGrain(Grain data, String batchTag) { |
| | | if (StringUtils.isEmpty(data.getCompanyId())) { |
| | | data.setCompanyId(ContextUtil.getCompanyId()); |
| | | } |
| | | if (StringUtils.isEmpty(data.getBatchId())) { |
| | | data.setBatchId(DateFormatUtils.format(data.getReceiveDate(), "yyyyMMddHHmm")); |
| | | } |
| | | if(StringUtils.isEmpty(batchTag)){ |
| | | //èªå¨çæ |
| | | batchTag = "01"; |
| | | } |
| | | |
| | | if(StringUtils.isBlank(data.getCreateBy())){ |
| | | data.setCreateBy(ContextUtil.getLoginUserName()); |
| | | data.setCreateTime(new Date()); |
| | | } |
| | | |
| | | data.setUpdateBy(ContextUtil.getLoginUserName()); |
| | | data.setUpdateTime(new Date()); |
| | | |
| | | data.setBatchTag(batchTag); |
| | | int insert = grainMapper.updateById(data); |
| | | if(insert == 0){ |
| | | grainMapper.insert(data); |
| | | } |
| | | |
| | | updateCacheGrainData(data); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * æ´æ°ç¼å䏿æ°çç²®æ
æ£æµæ°æ® |
| | | * |
| | | * @param data å½åæ°æ®ä¸ºæ åçGrainæ°æ®ï¼æ²¡æåæ´æ°ç¹ä½ä¿¡æ¯ |
| | | * @return key=åèç¼ç |
| | | */ |
| | | public void updateCacheGrainData(Grain data) { |
| | | |
| | | GrainData grainData = new GrainData(); |
| | | BeanUtils.copyProperties(data, grainData); |
| | | |
| | | String key = RedisConst.buildKey(data.getCompanyId(), |
| | | RedisConst.KEY_GRAIN, grainData.getDepotId()); |
| | | redisCache.setCacheObject(key, grainData); |
| | | |
| | | |
| | | //æ¨éå¤§å± |
| | | String deptId = data.getDeptId(); |
| | | if (null == deptId) { |
| | | Depot depot = depotService.getCacheDepot(data.getCompanyId(), data.getDepotId()); |
| | | if (null == depot) { |
| | | return; |
| | | } |
| | | deptId = depot.getDeptId(); |
| | | } |
| | | Map<String, GrainData> mapData = this.getCacheGrainDateMap(data.getCompanyId(), deptId); |
| | | WebSocketPacket packet = new WebSocketPacket(); |
| | | packet.setBizType("screen"); |
| | | packet.setCompanyId(ContextUtil.getCompanyId()); |
| | | packet.setDeptId(deptId); |
| | | packet.setBizId("grain"); |
| | | packet.setOrderResp(OrderRespEnum.ORDER_INPROGRESS.getCode()); |
| | | packet.setData(mapData); |
| | | WebSocketServer.sendByPocket(packet); |
| | | } |
| | | |
| | | /** |
| | | * è·åç¼å䏿æ°çç²®æ
æ£æµæ°æ® |
| | | * |
| | | * @param companyId |
| | | * @return key=åèç¼ç |
| | | */ |
| | | public Map<String, GrainData> getCacheGrainDateMap(String companyId, String deptId) { |
| | | if (null == companyId || null == deptId) return null; |
| | | |
| | | String pattern = RedisConst.buildKey(companyId, RedisConst.KEY_GRAIN) + "*"; |
| | | |
| | | Collection<String> keys = redisCache.keys(pattern); |
| | | |
| | | if (null == keys || keys.isEmpty()) return null; |
| | | |
| | | Map<String, GrainData> result = new HashMap<>(); |
| | | GrainData data; |
| | | for (String key : keys) { |
| | | data = (GrainData) redisCache.getCacheObject(key); |
| | | if (null == data) continue; |
| | | |
| | | result.put(data.getDepotId(), data); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | } |
| | |
| | | * @param data |
| | | */ |
| | | public void saveData(Quantity data) { |
| | | |
| | | data.setUpdateBy(ContextUtil.getLoginUserName()); |
| | | data.setUpdateTime(new Date()); |
| | | |
| | | if(StringUtils.isBlank(data.getCreateBy())){ |
| | | data.setCreateBy(ContextUtil.getLoginUserName()); |
| | | data.setCreateTime(new Date()); |
| | | } |
| | | quantityMapper.insert(data); |
| | | } |
| | | |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.fzzy.igds.service; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.fzzy.igds.constant.RedisConst; |
| | | import com.fzzy.igds.domain.WeatherCity; |
| | | import com.fzzy.igds.domain.WeatherConf; |
| | | import com.fzzy.igds.domain.WeatherInfo; |
| | | import com.fzzy.igds.mapper.WeatherCityMapper; |
| | | import com.fzzy.igds.mapper.WeatherConfMapper; |
| | | import com.fzzy.igds.mapper.WeatherInfoMapper; |
| | | import com.fzzy.igds.utils.ContextUtil; |
| | | import com.ruoyi.common.core.redis.RedisCache; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.time.DateFormatUtils; |
| | | import org.springframework.stereotype.Service; |
| | | import javax.annotation.Resource; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.concurrent.TimeUnit; |
| | | |
| | | /** |
| | | * @Description |
| | | * @Author CZT |
| | | * @Date 2026/01/09 11:55 |
| | | */ |
| | | @Slf4j |
| | | @Service |
| | | public class WeatherService { |
| | | |
| | | @Resource |
| | | private WeatherInfoMapper weatherInfoMapper; |
| | | @Resource |
| | | private WeatherConfMapper weatherConfMapper; |
| | | @Resource |
| | | private WeatherCityMapper weatherCityMapper; |
| | | @Resource |
| | | private RedisCache redisCache; |
| | | |
| | | /** |
| | | * æ¥è¯¢é
ç½®ä¿¡æ¯ |
| | | * |
| | | * @param companyId |
| | | * @param deptId |
| | | * @return |
| | | */ |
| | | public List<WeatherConf> getConfData(String companyId, String deptId) { |
| | | if (StringUtils.isEmpty(companyId)) { |
| | | companyId = ContextUtil.getCompanyId(); |
| | | } |
| | | if (StringUtils.isEmpty(deptId)) { |
| | | deptId = ContextUtil.subDeptId(null); |
| | | } |
| | | |
| | | QueryWrapper<WeatherConf> queryWrapper = new QueryWrapper<>(); |
| | | |
| | | queryWrapper.eq("company_id", companyId); |
| | | |
| | | queryWrapper.eq("dept_id", deptId); |
| | | |
| | | return weatherConfMapper.selectList(queryWrapper); |
| | | } |
| | | |
| | | /** |
| | | * æ¥è¯¢é
ç½®ä¿¡æ¯ |
| | | * |
| | | * @return |
| | | */ |
| | | public List<WeatherConf> getConfData() { |
| | | QueryWrapper<WeatherConf> queryWrapper = new QueryWrapper<>(); |
| | | return weatherConfMapper.selectList(queryWrapper); |
| | | } |
| | | |
| | | /** |
| | | * ä¿åé
ç½®ä¿¡æ¯ |
| | | * |
| | | * @param data |
| | | * @return |
| | | */ |
| | | public String saveConf(WeatherConf data) { |
| | | if (StringUtils.isEmpty(data.getId())) { |
| | | data.setId(ContextUtil.generateId()); |
| | | data.setCompanyId(ContextUtil.getCompanyId()); |
| | | data.setDeptId(ContextUtil.subDeptId(null)); |
| | | } |
| | | if(StringUtils.isBlank(data.getCreateBy())){ |
| | | data.setCreateBy(ContextUtil.getLoginUserName()); |
| | | data.setCreateTime(new Date()); |
| | | } |
| | | if(StringUtils.isBlank(data.getUpdateBy())){ |
| | | data.setUpdateBy(ContextUtil.getLoginUserName()); |
| | | data.setUpdateTime(new Date()); |
| | | } |
| | | weatherConfMapper.insert(data); |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * å é¤é
ç½®ä¿¡æ¯ |
| | | * |
| | | * @param data |
| | | * @return |
| | | */ |
| | | public String delConf(WeatherConf data) { |
| | | weatherConfMapper.deleteById(data); |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * ä¿åæ°æ¯ä¿¡æ¯ |
| | | * |
| | | * @param data |
| | | */ |
| | | private void addWeatherInfo(WeatherInfo data) { |
| | | |
| | | if(StringUtils.isBlank(data.getId())){ |
| | | data.setId(ContextUtil.UUID()); |
| | | } |
| | | if(StringUtils.isBlank(data.getCreateBy())){ |
| | | data.setCreateBy(ContextUtil.getLoginUserName()); |
| | | data.setCreateTime(new Date()); |
| | | } |
| | | if(StringUtils.isBlank(data.getUpdateBy())){ |
| | | data.setUpdateBy(ContextUtil.getLoginUserName()); |
| | | data.setUpdateTime(new Date()); |
| | | } |
| | | weatherInfoMapper.insert(data); |
| | | } |
| | | |
| | | /** |
| | | * å页æ¥è¯¢æ°æ® |
| | | * @param page |
| | | * @param param |
| | | */ |
| | | public void getInfoData(Page<WeatherInfo> page, Map<String, Object> param) { |
| | | |
| | | QueryWrapper<WeatherInfo> queryWrapper = new QueryWrapper<>(); |
| | | |
| | | queryWrapper.eq("company_id", ContextUtil.getCompanyId()); |
| | | queryWrapper.eq("dept_id", ContextUtil.subDeptId(null)); |
| | | |
| | | weatherInfoMapper.selectPage(page, queryWrapper); |
| | | } |
| | | |
| | | /** |
| | | * å页æ¥è¯¢æ°æ® |
| | | * @param page |
| | | * @param param |
| | | */ |
| | | public void pageCity(Page<WeatherCity> page, Map<String, Object> param) { |
| | | |
| | | QueryWrapper<WeatherCity> queryWrapper = new QueryWrapper<>(); |
| | | |
| | | weatherCityMapper.selectPage(page, queryWrapper); |
| | | } |
| | | |
| | | /** |
| | | * 夿æ°è±¡ä¿¡æ¯æ¯å¦éè¦ä¿å |
| | | * |
| | | * @param weather |
| | | */ |
| | | public void updateCacheAndSave(WeatherInfo weather) { |
| | | if (null == weather.getCompanyId()) { |
| | | weather.setCompanyId(ContextUtil.getCompanyId()); |
| | | } |
| | | try { |
| | | // æ´æ°ç¼å |
| | | updateCacheWeather(weather); |
| | | // 夿æ¯ä¸æ¯éè¦ä¿å |
| | | if (this.isSave(weather.getUpdateTime())) { |
| | | addWeatherInfo(weather); |
| | | } |
| | | |
| | | } catch (Exception e) { |
| | | String msg = e.getMessage(); |
| | | if (msg.indexOf("PRIMARY") > 0) { |
| | | log.error("æä¹
åæ°è±¡ä¿¡æ¯å¼å¸¸ï¼ä¸»é®å²çªï¼è¯·æ³¨ææ´æ°æ¶é´ï¼åºç°å¼å¸¸æ¯å¦åç"); |
| | | } else { |
| | | log.error("æ´æ°ä¿åæ°è±¡ä¿¡æ¯å¼å¸¸ï¼", e); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * æ ¹æ®ç»ç»ç¼ç 设置ç¼å |
| | | * |
| | | * @param weather |
| | | */ |
| | | public void updateCacheWeather(WeatherInfo weather) { |
| | | if (null == weather.getCompanyId()) { |
| | | weather.setCompanyId(ContextUtil.getCompanyId()); |
| | | } |
| | | String key = RedisConst.buildKey(weather.getCompanyId(), RedisConst.KEY_WEATHER_INFO); |
| | | log.debug("æ°è±¡ä¿¡æ¯æ´æ°å°ç¼åä¸ï¼info={}", weather.toString()); |
| | | redisCache.setCacheObject(key, weather); |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ®cityId设置ç¼å |
| | | * |
| | | * @param weather |
| | | * @param cityId |
| | | */ |
| | | public void setCacheWeatherByCityId(WeatherInfo weather, String cityId) { |
| | | String key = RedisConst.buildKey(RedisConst.KEY_WEATHER_INFO, cityId); |
| | | |
| | | log.debug("æ°è±¡ä¿¡æ¯æ´æ°å°ç¼åä¸ï¼info={}", weather.toString()); |
| | | redisCache.setCacheObject(key, weather, 60 * 30, TimeUnit.MICROSECONDS); |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ®cityIdè·åç¼åä¿¡æ¯ |
| | | * |
| | | * @param cityId |
| | | * @return |
| | | */ |
| | | public WeatherInfo getCacheWeatherByCityId(String cityId) { |
| | | String key = RedisConst.buildKey(RedisConst.KEY_WEATHER_INFO, cityId); |
| | | WeatherInfo info = (WeatherInfo) redisCache.getCacheObject(key); |
| | | if (null == info) { |
| | | log.error("ç¼å䏿²¡æè·åå°æ°è±¡ä¿¡æ¯ï¼ï¼"); |
| | | } |
| | | return info; |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ®companyIdè·åç¼åä¿¡æ¯ |
| | | * |
| | | * @param companyId |
| | | * @return |
| | | */ |
| | | public WeatherInfo getCacheWeather(String companyId) { |
| | | String key = RedisConst |
| | | .buildKey(companyId, RedisConst.KEY_WEATHER_INFO); |
| | | WeatherInfo info = (WeatherInfo) redisCache.getCacheObject(key); |
| | | if (null == info) { |
| | | log.error("ç¼å䏿²¡æè·åå°æ°è±¡ä¿¡æ¯ï¼ï¼"); |
| | | } |
| | | return info; |
| | | } |
| | | |
| | | /** |
| | | * åå»ºè¿æ¥ |
| | | * |
| | | * @param address |
| | | * @param port |
| | | */ |
| | | public void onCreate(String address, Integer port) { |
| | | log.debug("æ°è±¡ç«èªå¨è¿æ¥éç¥æä¸å¤çâ¦â¦"); |
| | | } |
| | | |
| | | /** |
| | | * 鿝龿¥ |
| | | * |
| | | * @param address |
| | | * @param port |
| | | */ |
| | | public void onDestroy(String address, Integer port) { |
| | | log.debug("æ°è±¡ç«èªå¨æå¼éç¥æä¸å¤çâ¦â¦"); |
| | | } |
| | | |
| | | /** |
| | | * 夿å½åæ°è±¡ä¿¡æ¯æ¯å¦éè¦æä¹
åï¼é»è®¤ç³»ç»åªä¿åå¨ä¸å8ç¹ åä¸å3ç¹çæ°è±¡ä¿¡ã |
| | | * |
| | | * @param updateTime |
| | | * @return |
| | | */ |
| | | public static boolean isSave(Date updateTime) { |
| | | |
| | | String tag = DateFormatUtils.format(updateTime, "HHmm"); |
| | | String tag1 = "0800"; |
| | | String tag2 = "1500"; |
| | | |
| | | if (tag.equals(tag1) || tag.equals(tag2)) { |
| | | return true; |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | } |
| | |
| | | package com.fzzy.igds.utils; |
| | | |
| | | import com.fzzy.igds.camera.data.ydqly.YdQlyNode; |
| | | import com.fzzy.igds.constant.GrainFrequence; |
| | | import com.ruoyi.common.config.FrameworkConfig; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.utils.ShiroUtils; |
| | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * æ ¹æ®ç³»ç»é
ç½®çæ¹æ¬¡é¢çè·åæ¹æ¬¡ç¼å· |
| | | * |
| | | * @param freq |
| | | * @return |
| | | */ |
| | | public static String getBatchIdByFireq(String freq) { |
| | | // ä¸å¤©ä¸æ¬¡ |
| | | if (GrainFrequence.FREQ_02.getCode().equals(freq)) { |
| | | return DateFormatUtils.format(new Date(), "yyyyMMdd") + "1801"; |
| | | } |
| | | |
| | | // ä¸å¤©ä¸¤æ¬¡ |
| | | if (GrainFrequence.FREQ_03.getCode().equals(freq)) { |
| | | String hour = DateFormatUtils.format(new Date(), "HH"); |
| | | if (Integer.valueOf(hour) >= 0 && Integer.valueOf(hour) <= 12) { |
| | | return DateFormatUtils.format(new Date(), "yyyyMMdd") + "1301"; |
| | | } else { |
| | | return DateFormatUtils.format(new Date(), "yyyyMMdd") + "1802"; |
| | | } |
| | | } |
| | | return getDefaultBatchId(); |
| | | } |
| | | |
| | | public static String getDefaultBatchId() { |
| | | return DateFormatUtils.format(new Date(), "yyyyMMddHHmm"); |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | for (int i = 0; i < 10; i++){ |
| | | String id = generateId(); |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.fzzy.igds.utils; |
| | | |
| | | import org.springframework.beans.BeansException; |
| | | import org.springframework.context.ApplicationContext; |
| | | import org.springframework.context.ApplicationContextAware; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | @Component |
| | | public class SpringUtil implements ApplicationContextAware { |
| | | |
| | | private static ApplicationContext applicationContext; |
| | | |
| | | @Override |
| | | public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { |
| | | if (SpringUtil.applicationContext == null) { |
| | | SpringUtil.applicationContext = applicationContext; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * è·åapplicationContext |
| | | * @return |
| | | */ |
| | | public static ApplicationContext getApplicationContext() { |
| | | return applicationContext; |
| | | } |
| | | |
| | | /** |
| | | * éè¿nameè·å Bean. |
| | | * @param name |
| | | * @return |
| | | */ |
| | | public static Object getBean(String name) { |
| | | return getApplicationContext().getBean(name); |
| | | } |
| | | |
| | | /** |
| | | * éè¿classè·åBean. |
| | | * @param clazz |
| | | * @param <T> |
| | | * @return |
| | | */ |
| | | public static <T> T getBean(Class<T> clazz) { |
| | | return getApplicationContext().getBean(clazz); |
| | | } |
| | | |
| | | /** |
| | | * éè¿name,以åClazzè¿åæå®çBean |
| | | * @param name |
| | | * @param clazz |
| | | * @param <T> |
| | | * @return |
| | | */ |
| | | public static <T> T getBean(String name, Class<T> clazz) { |
| | | return getApplicationContext().getBean(name, clazz); |
| | | } |
| | | |
| | | } |
| | |
| | | package com.fzzy.igds; |
| | | |
| | | import com.fzzy.igds.iot.server.IotServerEngine; |
| | | import com.fzzy.igds.quantity.server.BhznQuantityServerEngine; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.boot.CommandLineRunner; |
| | |
| | | public static final String BEAN_ID = "quantity.serverRunner"; |
| | | |
| | | @Resource |
| | | private BhznQuantityServerEngine serverEngine; |
| | | private BhznQuantityServerEngine quantityServerEngine; |
| | | @Resource |
| | | private IotServerEngine iotServerEngine; |
| | | |
| | | @Override |
| | | public void run(String... strings) throws Exception { |
| | | |
| | | serverEngine.start(BhznQuantityServerEngine.PORT); |
| | | //æ°éæ£æµç«¯å£ |
| | | quantityServerEngine.start(BhznQuantityServerEngine.PORT); |
| | | |
| | | //IOT设å¤ç«¯å£ |
| | | iotServerEngine.start(IotServerEngine.PORT); |
| | | |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.fzzy.igds.io.notify; |
| | | |
| | | import com.fzzy.igds.constant.OrderRespEnum; |
| | | import com.fzzy.igds.domain.Depot; |
| | | import com.fzzy.igds.domain.DepotConf; |
| | | import com.fzzy.igds.domain.Grain; |
| | | import com.fzzy.igds.request.ExeBaseRequest; |
| | | |
| | | /** |
| | | * @author Andy |
| | | */ |
| | | public interface NotifyGrainInvoker { |
| | | |
| | | |
| | | /** |
| | | * ç²®æ
è§£ææååéç¥ï¼ç³»ç»å¼å§æ§è¡ä¿å夿çæä½ |
| | | * |
| | | * @param grain è§£æåçç²®æ
ä¿¡æ¯ |
| | | * @param depotConf ä»åºé
置信æ¯ï¼ä¸å¯ä¸ºç©º |
| | | * @return æ§è¡å¼å¸¸ä¿¡æ¯ï¼æ£å¸¸è¿åNULL |
| | | */ |
| | | String analysisSuccess(Grain grain, DepotConf depotConf, Depot depot, boolean isNotifyWeb, ExeBaseRequest request); |
| | | |
| | | /** |
| | | * æ´æ°ç²®æ
ï¼ä»
ä»
ç²®æ
ä¿¡æ¯ |
| | | * |
| | | * @param grain |
| | | * @param depot ä»åºä¿¡æ¯ |
| | | */ |
| | | String analysisSuccess(Grain grain, Depot depot); |
| | | |
| | | /** |
| | | * æ´æ°ç²®æ
ï¼ä»
ä»
ç²®æ
ä¿¡æ¯ |
| | | * |
| | | * @param grain |
| | | * @param request 请æ±å½ä»¤ä¿¡æ¯ |
| | | */ |
| | | String analysisSuccess(Grain grain, Depot depot, ExeBaseRequest request); |
| | | |
| | | /** |
| | | * æ´æ°ç²®æ
ï¼ä»
ä»
ç²®æ
ä¿¡æ¯ |
| | | * |
| | | * @param grain |
| | | * @param request 请æ±å½ä»¤ä¿¡æ¯ |
| | | */ |
| | | String analysisSuccess(Grain grain, Depot depot, ExeBaseRequest request, DepotConf depotConf); |
| | | |
| | | |
| | | /** |
| | | * ç´æ¥éç¥é¡µé¢ |
| | | * |
| | | * @param companyId |
| | | * @param orderResp |
| | | * @param notifyMsg |
| | | */ |
| | | void notifyWeb(String companyId, OrderRespEnum orderResp, String bizType, String notifyMsg); |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.fzzy.igds.io.notify; |
| | | |
| | | import com.fzzy.igds.constant.GrainFrequence; |
| | | import com.fzzy.igds.constant.OrderRespEnum; |
| | | import com.fzzy.igds.domain.Depot; |
| | | import com.fzzy.igds.domain.DepotConf; |
| | | import com.fzzy.igds.domain.Grain; |
| | | import com.fzzy.igds.domain.WeatherInfo; |
| | | import com.fzzy.igds.io.order.ExeOrderService; |
| | | import com.fzzy.igds.request.ExeBaseRequest; |
| | | import com.fzzy.igds.service.GrainService; |
| | | import com.fzzy.igds.service.WeatherService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | @Slf4j |
| | | @Component |
| | | public class NotifyGrainInvokerImpl extends NotifyWebParent implements NotifyGrainInvoker { |
| | | |
| | | @Resource |
| | | private GrainService grainService; |
| | | @Resource |
| | | private ExeOrderService exeRequestService; |
| | | @Resource |
| | | private WeatherService weatherService; |
| | | |
| | | @Override |
| | | public String analysisSuccess(Grain grain, DepotConf depotConf, Depot depot, boolean isNotifyWeb, ExeBaseRequest exeRequest) { |
| | | grain = addWeatherInfo(grain); |
| | | try { |
| | | // 妿æ¯ä¸æ¥å¤æ¬¡ |
| | | if (null == depotConf) { |
| | | grainService.saveOrUpdateGrain(grain, null); |
| | | } else { |
| | | if (depotConf.getGrainFreq().equals( |
| | | GrainFrequence.FREQ_01.getCode())) { |
| | | grainService.saveOrUpdateGrain(grain, null); |
| | | } else { |
| | | grainService.saveOrUpdateGrain(grain, null); |
| | | } |
| | | } |
| | | String notifyMsg = depot.getName() + " ç²®æ
ééå¹¶è§£ææåï¼æ¹æ¬¡å·=" + grain.getBatchId(); |
| | | //宿 |
| | | exeRequest.setExeMsg(notifyMsg); |
| | | exeRequestService.completeCache(exeRequest, false); |
| | | |
| | | notifyWeb(depotConf.getCompanyId(), OrderRespEnum.MSG_SUCCESS, "grain", notifyMsg); |
| | | |
| | | log.info(depot.getName() + "ç²®æ
è§£ææå:" + grain.getBatchId()); |
| | | |
| | | } catch (Exception e) { |
| | | String notifyMsg = depot.getName() + "-ä¿å失败ï¼è¯·å¿2åéå
éå¤éé"; |
| | | //宿 |
| | | exeRequest.setErrorMsg(notifyMsg); |
| | | exeRequestService.completeCache(exeRequest, false); |
| | | notifyWeb(depotConf.getCompanyId(), OrderRespEnum.MSG_ERROR, "grain", notifyMsg); |
| | | log.error(depot.getName() + "ç²®æ
è§£æä¿å失败ï¼" + e); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public String analysisSuccess(Grain grain, Depot depot) { |
| | | grain = addWeatherInfo(grain); |
| | | |
| | | try { |
| | | grainService.saveOrUpdateGrain(grain,null); |
| | | |
| | | String notifyMsg = depot.getName() + " æ¶å°æ¨éç²®æ
ä¿¡æ¯å¹¶è§£ææåï¼æ¹æ¬¡å·=" + grain.getBatchId(); |
| | | |
| | | notifyWeb(grain.getCompanyId(), OrderRespEnum.MSG_SUCCESS, "grain", notifyMsg); |
| | | |
| | | } catch (Exception e) { |
| | | String notifyMsg = depot.getName() + "-ä¿å失败ï¼è¯·å¿2åéå
éå¤éé"; |
| | | this.notifyWeb(grain.getCompanyId(), OrderRespEnum.MSG_ERROR, "grain", notifyMsg); |
| | | |
| | | log.error("ç²®æ
è§£æä¿å失败ï¼" + e); |
| | | return notifyMsg; |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public String analysisSuccess(Grain grain, Depot depot, ExeBaseRequest exeRequest) { |
| | | |
| | | grain = addWeatherInfo(grain); |
| | | try { |
| | | grainService.saveOrUpdateGrain(grain,null); |
| | | |
| | | String notifyMsg = exeRequest.getDepotName() + " ç²®æ
ééå¹¶è§£ææåï¼æ¹æ¬¡å·=" + grain.getBatchId(); |
| | | |
| | | //宿 |
| | | exeRequest.setExeMsg(notifyMsg); |
| | | exeRequestService.completeCache(exeRequest, false); |
| | | |
| | | } catch (Exception e) { |
| | | String notifyMsg = exeRequest.getDepotName() + "-ä¿å失败ï¼è¯·å¿2åéå
éå¤éé"; |
| | | //宿 |
| | | exeRequest.setErrorMsg(notifyMsg); |
| | | exeRequestService.completeCache(exeRequest, false); |
| | | return notifyMsg; |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public String analysisSuccess(Grain grain, Depot depot, ExeBaseRequest exeRequest, DepotConf depotConf) { |
| | | |
| | | grain = addWeatherInfo(grain); |
| | | try { |
| | | grainService.saveOrUpdateGrain(grain,null); |
| | | |
| | | String notifyMsg = exeRequest.getDepotName() + " ç²®æ
ééå¹¶è§£ææåï¼æ¹æ¬¡å·=" + grain.getBatchId(); |
| | | |
| | | //宿 |
| | | exeRequest.setExeMsg(notifyMsg); |
| | | exeRequestService.completeCache(exeRequest, false); |
| | | |
| | | notifyWeb(depotConf.getCompanyId(), OrderRespEnum.MSG_SUCCESS, "grain", notifyMsg); |
| | | log.info(depot.getName() + "ç²®æ
è§£ææå:" + grain.getBatchId()); |
| | | } catch (Exception e) { |
| | | String notifyMsg = exeRequest.getDepotName() + "-ä¿å失败ï¼è¯·å¿2åéå
éå¤éé"; |
| | | |
| | | //宿 |
| | | exeRequest.setErrorMsg(notifyMsg); |
| | | exeRequestService.completeCache(exeRequest, false); |
| | | |
| | | notifyWeb(depotConf.getCompanyId(), OrderRespEnum.MSG_ERROR, "grain", notifyMsg); |
| | | |
| | | log.error(depot.getName() + "ç²®æ
è§£æä¿å失败ï¼" + e); |
| | | return notifyMsg; |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | |
| | | // ä»ç¼åä¸è·åå½åç夿¸©åº¦å¤é¨æ¹¿åº¦ |
| | | private Grain addWeatherInfo(Grain grain) { |
| | | if(grain.getHumidityOut() != null && grain.getTempOut() != null){ |
| | | return grain; |
| | | } |
| | | WeatherInfo weatherInfo = weatherService.getCacheWeather(grain.getCompanyId()); |
| | | Double tOut = -100.0, hOut = -100.0; |
| | | if (null != weatherInfo) { |
| | | if (weatherInfo.getTemp().indexOf("â") > 0) { |
| | | weatherInfo.setTemp(weatherInfo.getTemp().replace("â", "")); |
| | | } |
| | | if (weatherInfo.getHumidity().indexOf("%") > 0) { |
| | | weatherInfo.setHumidity(weatherInfo.getHumidity().replace("%", |
| | | "")); |
| | | } |
| | | tOut = Double.valueOf(weatherInfo.getTemp()); |
| | | hOut = Double.valueOf(weatherInfo.getHumidity()); |
| | | grain.setWeather(weatherInfo.getWeather()); |
| | | } |
| | | if(grain.getHumidityOut() == null || grain.getHumidityOut() == 0.0){ |
| | | grain.setHumidityOut(hOut); |
| | | } |
| | | if(grain.getTempOut() == null || grain.getTempOut() == 0.0){ |
| | | grain.setTempOut(tOut); |
| | | } |
| | | return grain; |
| | | } |
| | | |
| | | } |
| ÎļþÃû´Ó fzzy-igdss-core/src/main/java/com/fzzy/igds/notify/NotifyWebInvoker.java ÐÞ¸Ä |
| | |
| | | package com.fzzy.igds.notify; |
| | | package com.fzzy.igds.io.notify; |
| | | |
| | | import com.fzzy.igds.constant.OrderRespEnum; |
| | | import com.fzzy.igds.data.QuantityProgressData; |
| ÎļþÃû´Ó fzzy-igdss-core/src/main/java/com/fzzy/igds/notify/NotifyWebInvokerImpl.java ÐÞ¸Ä |
| | |
| | | package com.fzzy.igds.notify; |
| | | package com.fzzy.igds.io.notify; |
| | | |
| | | import com.fzzy.igds.constant.OrderRespEnum; |
| | | import com.fzzy.igds.data.QuantityProgressData; |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.fzzy.igds.io.notify; |
| | | |
| | | import com.fzzy.igds.constant.OrderRespEnum; |
| | | import com.fzzy.igds.websocket.WebSocketPacket; |
| | | import com.fzzy.igds.websocket.WebSocketServer; |
| | | |
| | | public class NotifyWebParent { |
| | | |
| | | public void notifyWeb(String companyId, OrderRespEnum orderResp, |
| | | String bizType, String notifyMsg) { |
| | | // éç¥å端 |
| | | WebSocketPacket packet = new WebSocketPacket(); |
| | | packet.setBizType(bizType); |
| | | packet.setCompanyId(companyId); |
| | | packet.setOrderResp(orderResp.getCode()); |
| | | packet.setData(notifyMsg); |
| | | WebSocketServer.sendByPocket(packet); |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.fzzy.igds.io.notify; |
| | | |
| | | import com.fzzy.igds.domain.DeviceSer; |
| | | |
| | | /** |
| | | * æå¡éç¥ç¨åºè°ç¨ï¼ç¨äºéç¥åæºä¸çº¿å离线å¤ç |
| | | * @author Andy |
| | | * |
| | | */ |
| | | public interface ServerNotifyInvoker { |
| | | |
| | | public static final String BEAN_ID = "serverNotifyInvoker"; |
| | | |
| | | /** |
| | | * è¿æ¥è¢«éæ¯åéç¥ä¿¡æ¯ |
| | | * @param businessKey TCPä¸å¡KEY |
| | | * @param ip 设å¤IP |
| | | * @param port 设å¤ç«¯å£å· |
| | | */ |
| | | void connectDestory(String businessKey, String ip, Integer port); |
| | | |
| | | /** |
| | | * è¿æ¥è¢«æ¿æ´»çéç¥ |
| | | * @param businessKey TCPä¸å¡KEY |
| | | * @param address 设å¤IP |
| | | * @param port 设å¤ç«¯å£å· |
| | | */ |
| | | void connectActive(String businessKey, String address, Integer port); |
| | | |
| | | |
| | | /** |
| | | * æ ¹æ®ä¿¡æ¯è·åæ§å¶æä¿¡æ¯ |
| | | * @param companyId |
| | | * @param address |
| | | * @param port |
| | | * @return |
| | | */ |
| | | DeviceSer getDeviceSer(String companyId, String address, Integer port); |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.fzzy.igds.iot.analysis; |
| | | |
| | | import com.fzzy.igds.constant.Constant; |
| | | import com.fzzy.igds.constant.OrderRespEnum; |
| | | import com.fzzy.igds.constant.RedisConst; |
| | | import com.fzzy.igds.data.GrainData; |
| | | import com.fzzy.igds.domain.*; |
| | | import com.fzzy.igds.io.notify.NotifyGrainInvoker; |
| | | import com.fzzy.igds.iot.analysis.builder.ReMessageBuilder; |
| | | import com.fzzy.igds.iot.analysis.message.DeviceAttr; |
| | | import com.fzzy.igds.iot.analysis.message.DeviceAttrInfo; |
| | | import com.fzzy.igds.io.notify.NotifyWebInvoker; |
| | | import com.fzzy.igds.service.*; |
| | | import com.fzzy.igds.utils.ContextUtil; |
| | | import com.ruoyi.common.core.redis.RedisCache; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | import javax.annotation.Resource; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @Description è§£æå
¥å£ |
| | | * @Author CZT |
| | | * @Date 2025/11/11 18:20 |
| | | */ |
| | | @Slf4j |
| | | @Component(AnalysisService.BEAN_ID) |
| | | public class AnalysisService { |
| | | |
| | | public static final String BEAN_ID = "iot.analysisService"; |
| | | |
| | | @Resource |
| | | private DeviceSerService deviceSerService; |
| | | @Resource |
| | | private DeviceIotService deviceIotService; |
| | | @Autowired |
| | | private DepotService depotService; |
| | | @Autowired |
| | | private NotifyWebInvoker notifyWebInvoker; |
| | | @Autowired |
| | | private DepotConfService depotConfService; |
| | | @Autowired |
| | | private NotifyGrainInvoker notifyGrainInvoker; |
| | | @Resource |
| | | private QuantityService quantityService; |
| | | |
| | | @Resource |
| | | private RedisCache redisCache; |
| | | |
| | | /** |
| | | * @param sessionKey ip:port |
| | | * @param msg |
| | | */ |
| | | public void analysis(String sessionKey, String msg) throws Exception { |
| | | String[] attr = sessionKey.split(":"); |
| | | String ip = attr[0]; |
| | | Integer port = Integer.valueOf(attr[1]); |
| | | |
| | | DeviceAttr reMessage = ReMessageBuilder.getInstance().buildMessage( ip, port, msg); |
| | | |
| | | if (null == reMessage || null == reMessage.getOrgId()) { |
| | | log.error("IOTç½å
³----->>>å¹³å°ï¼è¿åä¿¡æ¯æ²¡æè·åç»ç»ç¼ç ä¿¡æ¯ï¼æ æ³ç»§ç»è§£æ----{}", sessionKey); |
| | | return; |
| | | } |
| | | |
| | | DeviceSer ser = deviceSerService.getCacheSerBySn(reMessage.getOrgId(),reMessage.getSn()); |
| | | if (null == ser) { |
| | | String info = "IOTç½å
³=" + reMessage.getDeviceId() + "è¿åä¿¡æ¯æ²¡æå¹é
å°åæºï¼å¿½ç¥æ¶æ¯ã"; |
| | | log.error("IOTç½å
³----->>>å¹³å°ï¼" + info); |
| | | notifyWebInvoker.notifyWeb(reMessage.getOrgId(), OrderRespEnum.MSG_ERROR,"SYS", info); |
| | | // æ¸
é¤ç¼å并鿝龿¥ |
| | | return; |
| | | } |
| | | |
| | | //æ´æ°åæºç¶æ |
| | | ser.setIp(ip); |
| | | ser.setPort(port); |
| | | ser.setStatus(Constant.YN_Y); |
| | | deviceSerService.updateByData(ser); |
| | | log.debug("IOTç½å
³----->>>å¹³å°ï¼æå±ç»ç»-{}ï¼åæº-{} è¿åçå½ä»¤ä¿¡æ¯={}", ser.getCompanyId(), ser.getName(), reMessage.toString()); |
| | | List<DeviceIot> deviceIots = deviceIotService.getCacheDeviceIotBySerId(ser.getCompanyId(),ser.getId()); |
| | | if(deviceIots == null || deviceIots.size() <= 0){ |
| | | log.error("IOTç½å
³----->>>å¹³å°ï¼" + "没æè·åå°åæºä¸é¢æè®¾å¤!"); |
| | | return ; |
| | | } |
| | | |
| | | DeviceIot deviceIot = deviceIots.stream().filter(item -> (item.getPassCode()+"").equals(reMessage.getDeviceId())).findAny().orElse(null); |
| | | if(deviceIot == null ){ |
| | | log.error("IOTç½å
³----->>>å¹³å°ï¼" + "没æè·åå°è®¾å¤å个!"); |
| | | return ; |
| | | } |
| | | |
| | | log.info("IOTç½å
³----->>>å¹³å°ï¼"+ "å¼å§è§£ææ°æ®" + reMessage.toString()); |
| | | if(StringUtils.isEmpty(reMessage.getType())){ |
| | | //æ¶²ä½è§£æ |
| | | analysisHeight(reMessage, ser,deviceIot); |
| | | } |
| | | if("2".equals(reMessage.getType()) || "02".equals(reMessage.getType())){ |
| | | //油温解æ |
| | | analysisOilGrain(reMessage, ser,deviceIot); |
| | | }else { |
| | | //æ¶²ä½è§£æ |
| | | analysisHeight(reMessage, ser,deviceIot); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * ç½ç®¡æ²¹æ
è§£æ |
| | | * @param deviceAttr |
| | | * @param ser |
| | | */ |
| | | public void analysisOilGrain(DeviceAttr deviceAttr, DeviceSer ser, DeviceIot deviceIot) { |
| | | try { |
| | | log.info("IOTç½å
³----->>>å¹³å°ï¼"+ "å¼å§è§£ææ¸©åº¦æ°æ®" + deviceAttr.toString()); |
| | | List<DeviceAttrInfo> list = deviceAttr.getTerminalAttrInfoList(); |
| | | if(null == list || list.isEmpty()){ |
| | | log.error("IOTç½å
³----->>>å¹³å°ï¼" + "æ²¹æ
æ°æ®ä¸ºç©ºï¼ä¸è§£æ!"); |
| | | return; |
| | | } |
| | | |
| | | Integer ceng = 0; |
| | | String points = ""; |
| | | Double max = null, min = null, sumT = 0.0; |
| | | Double temp = 0.0; |
| | | for (DeviceAttrInfo iotInfo : list) { |
| | | if("1".equals(iotInfo.getPasscode()) || "2".equals(iotInfo.getPasscode())){ |
| | | //ééå·ä¸º1æè
2æ¶ï¼æ¯éä¿¡ç¶æååè¦ç¶æï¼ä¸è§£æ |
| | | continue; |
| | | } |
| | | points += iotInfo.getValue() + ","; |
| | | ceng ++; |
| | | |
| | | temp = Double.valueOf(iotInfo.getValue()); |
| | | if(null == max){ |
| | | max = temp; |
| | | } |
| | | if(null == min){ |
| | | min = temp; |
| | | } |
| | | if (temp > max) { |
| | | max = temp; |
| | | } |
| | | if (temp < min) { |
| | | min = temp; |
| | | } |
| | | sumT += temp; |
| | | } |
| | | |
| | | DepotConf depotConf = depotConfService.getCacheDepotConfByDepotId(ser.getCompanyId(), deviceIot.getDepotId()); |
| | | Depot depot = depotService.getCacheDepot(ser.getCompanyId(), deviceIot.getDepotId()); |
| | | Grain grain = new Grain(); |
| | | grain.setBatchId(ContextUtil.getBatchIdByFireq(depotConf.getGrainFreq())); |
| | | grain.setReceiveDate(new Date()); |
| | | grain.setCable("1"); |
| | | grain.setCableCir(ceng + ""); |
| | | grain.setPoints(points); |
| | | grain.setCheckUser("ç³»ç»"); |
| | | grain.setDepotId(deviceIot.getDepotId()); |
| | | grain.setCompanyId(depotConf.getCompanyId()); |
| | | |
| | | grain.setHumidityIn(-100.0); |
| | | grain.setTempIn(-100.0); |
| | | |
| | | grain.setTempAve(sumT/ceng); |
| | | grain.setTempMax(max); |
| | | grain.setTempMin(min); |
| | | grain.setDeptId(depot.getDeptId()); |
| | | |
| | | //æ²¹ç½ æ¶²ä½é«åº¦ï¼æå°±èµå¼ |
| | | GrainData data = (GrainData) redisCache.getCacheObject(RedisConst.buildKey(ser.getCompanyId(),RedisConst.KEY_DEPOT_HEIGHT,grain.getDepotId())); |
| | | if(data!= null && StringUtils.isNotEmpty(data.getOilHeight())){ |
| | | grain.setOilHeight(data.getOilHeight()); |
| | | } |
| | | |
| | | // ç¨æ·å°è£
å¥½æ°æ®å³å¯ |
| | | notifyGrainInvoker.analysisSuccess(grain, depot); |
| | | log.info("IOTç½å
³----->>>å¹³å°ï¼æ²¹æ¸©è§£æå®æï¼" + data); |
| | | } catch (Exception e) { |
| | | log.error(e.getMessage(), e); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * ç½ç®¡æ¶²ä½é«åº¦è§£æ |
| | | * @param deviceAttr |
| | | * @param ser |
| | | */ |
| | | public void analysisHeight(DeviceAttr deviceAttr, DeviceSer ser, DeviceIot deviceIot) { |
| | | try { |
| | | Depot depot = depotService.getCacheDepot(ser.getCompanyId(), deviceIot.getDepotId()); |
| | | if(null == depot){ |
| | | log.error("IOTç½å
³----->>>å¹³å°ï¼" + "æªè·åä»åºä¿¡æ¯ï¼ä¸è§£æ!"); |
| | | return; |
| | | } |
| | | |
| | | List<DeviceAttrInfo> list = deviceAttr.getTerminalAttrInfoList(); |
| | | if(null == list || list.isEmpty()){ |
| | | log.error("IOTç½å
³----->>>å¹³å°ï¼" + "æ²¹æ
æ°æ®ä¸ºç©ºï¼ä¸è§£æ!"); |
| | | return; |
| | | } |
| | | |
| | | Double diameter = 0.0; //ç´å¾ |
| | | Double volume = 0.0; //ä½ç§¯ |
| | | Double bulkWeight = 0.0; //容é |
| | | Double realHeight = 0.0; //页é¢é«åº¦ |
| | | Double maxHeight = 0.0; //æå¤§é«åº¦ |
| | | Double storage = 0.0; //计ç®å¨é |
| | | Double heightPer = 0.0; //é«åº¦ç¾åæ¯ |
| | | |
| | | if(null != depot.getHeight()){ |
| | | maxHeight = depot.getHeight(); |
| | | } |
| | | if(null != depot.getLength()){ |
| | | diameter = depot.getLength(); |
| | | } |
| | | if(null != depot.getBulkWeight()){ |
| | | bulkWeight = depot.getBulkWeight(); |
| | | } |
| | | //è§£æçå®é«åº¦ |
| | | realHeight = Double.valueOf(list.get(2).getValue()); |
| | | |
| | | //计ç®ä½ç§¯ |
| | | volume = 3.14159 * Math.pow(diameter / 2, 2) * realHeight; |
| | | //夿ä½ç§¯æ¯å¦ä¸ºè´ï¼ä¸ºè´å¼åä¸è®¡ç®ï¼é置为0 |
| | | if (volume < 0) { |
| | | volume = 0.0; |
| | | } |
| | | |
| | | //计ç®éé |
| | | storage = volume * bulkWeight; |
| | | storage = Double.valueOf(String.format("%.2f", storage)); |
| | | |
| | | //é«åº¦ç¾åæ¯ |
| | | if(maxHeight > 0){ |
| | | heightPer = Double.valueOf(String.format("%.2f", realHeight/maxHeight * 100)); |
| | | } |
| | | |
| | | Quantity data = new Quantity(); |
| | | |
| | | data.setBatchId(depot + ContextUtil.generateId()); |
| | | data.setCompanyId(ser.getCompanyId()); |
| | | data.setDeptId(depot.getDeptId()); |
| | | data.setDepotId(deviceIot.getDepotId()); |
| | | |
| | | data.setDiameter(depot.getLength()); |
| | | data.setHeightPer(heightPer); |
| | | data.setHeight(realHeight); |
| | | data.setBulk(volume); |
| | | data.setWeight(storage); |
| | | |
| | | data.setReceiveDate(new Date()); |
| | | data.setCheckUser("ç³»ç»"); |
| | | |
| | | quantityService.saveData( data); |
| | | |
| | | log.info("é«åº¦è§£æå®æï¼" + data); |
| | | |
| | | } catch (Exception e) { |
| | | log.error(e.getMessage(), e); |
| | | } |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.fzzy.igds.iot.analysis.builder; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.fzzy.igds.iot.analysis.message.DeviceAttr; |
| | | import com.fzzy.igds.iot.analysis.message.DeviceAttrInfo; |
| | | import com.fzzy.igds.iot.analysis.message.IoMessage; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @Description æ ¹æ®æ¥æ¶å°çä¿¡æ¯è¿è¡å°è£
|
| | | * @Author CZT |
| | | * @Date 2025/11/11 18:15 |
| | | */ |
| | | public class ReMessageBuilder { |
| | | public static final String CHARSET = "UTF-8"; |
| | | public static final String PREFIX = "<FZZY>"; |
| | | public static final String SUFFIX = "<EEEE>"; |
| | | public final static String ERROR_TAG = "null"; |
| | | public final static String ERROR_STR = "#"; |
| | | private final static ReMessageBuilder instance = new ReMessageBuilder(); |
| | | |
| | | private ReMessageBuilder() { |
| | | } |
| | | |
| | | public static ReMessageBuilder getInstance() { |
| | | return instance; |
| | | } |
| | | |
| | | /** |
| | | * @param ip |
| | | * @param port |
| | | * @param message |
| | | * @return |
| | | */ |
| | | public DeviceAttr buildMessage( String ip, int port, String message) throws Exception { |
| | | IoMessage ioMessage = JSON.parseObject(message, IoMessage.class); |
| | | JSONArray passCodeArray = JSON.parseArray(ioMessage.getContent()); |
| | | if (passCodeArray == null || passCodeArray .size() == 0) { |
| | | return null; |
| | | } |
| | | List<DeviceAttrInfo> terminalAttrInfoList = new ArrayList<>(); |
| | | JSONObject passCode = null; |
| | | for(int i = 0; i< passCodeArray.size(); i++ ){ |
| | | passCode = passCodeArray.getJSONObject(i); |
| | | if(passCode == null){ |
| | | continue; |
| | | } |
| | | DeviceAttrInfo terminalAttrInfo = new DeviceAttrInfo(); |
| | | terminalAttrInfo.setPasscode(passCode.getString("passcode")); |
| | | terminalAttrInfo.setTime(ioMessage.getTime()); |
| | | String value = passCode.getString("value"); |
| | | // null 弿¿æ¢ä¸º#å· |
| | | if(ERROR_TAG.equals(value))value = ERROR_STR; |
| | | terminalAttrInfo.setValue(value); |
| | | terminalAttrInfoList.add(terminalAttrInfo); |
| | | } |
| | | DeviceAttr request = new DeviceAttr(); |
| | | request.setSn(ioMessage.getSn()); |
| | | request.setOrderId(ioMessage.getOrderId()); |
| | | request.setOrgId(ioMessage.getOrgId()); |
| | | request.setGroupId(ioMessage.getGroupId()); |
| | | request.setGatewayId(ioMessage.getIedId()); |
| | | request.setDeviceId(ioMessage.getDeviceId()); |
| | | request.setTerminalAttrInfoList(terminalAttrInfoList); |
| | | request.setType(ioMessage.getType()); |
| | | return request; |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.fzzy.igds.iot.analysis.message; |
| | | |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @Description è¿ç¨æ´æ°ç»ç«¯è®¾å¤ç屿§å¼ï¼åå
¥åæ§å¶ä½¿ç¨ |
| | | * @Author CZT |
| | | * @Date 2025/11/11 18:12 |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = false) |
| | | public class DeviceAttr { |
| | | |
| | | private String orderId;// 订åå·ï¼å®¢æ·ç«¯ä¿è¯å¯ä¸ |
| | | private String orgId;//æå±ç»ç» |
| | | private String groupId;//æå±åç» |
| | | private String gatewayId;//ç½å
³ä¸æ è¯ |
| | | private String sn; |
| | | private String deviceId;// ç»ç«¯ç¼å· |
| | | private String type;// ç±»å:01-æ¶²ä½é«åº¦ï¼02-æ¸©åº¦ä¿¡æ¯ |
| | | private List<DeviceAttrInfo> terminalAttrInfoList; |
| | | private DeviceAttrInfo deviceAttrInfo; |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.fzzy.igds.iot.analysis.message; |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * @Description ç»ç«¯è®¾å¤ç屿§ä¿¡æ¯ |
| | | * @Author CZT |
| | | * @Date 2025/11/11 18:09 |
| | | */ |
| | | @Data |
| | | public class DeviceAttrInfo { |
| | | private String name;//ééåç§°ï¼å³å±æ§åç§° |
| | | private String passcode;//ééç¼ç ï¼å³å±æ§ç¼ç |
| | | private String value;//屿§å¼ |
| | | private String time;//æ¶é´ ç¨æ¥æ è¯å±æ§æ¯å¦äº§çäºåå |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.fzzy.igds.iot.analysis.message; |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * @Description ç»ç«¯è®¾å¤ç屿§ä¿¡æ¯ |
| | | * @Author CZT |
| | | * @Date 2025/11/11 18:09 |
| | | */ |
| | | @Data |
| | | public class IoMessage { |
| | | private String orgId; |
| | | private String groupId; |
| | | private String iedId; |
| | | private String functionId; |
| | | private String deviceId; |
| | | private String result; |
| | | private String orderId; |
| | | private String time; |
| | | private String signHeader; |
| | | private String len; |
| | | private String content; |
| | | private String signBody; |
| | | private String file;//éä»¶ |
| | | private byte[] fileBytes; |
| | | private String sn; |
| | | private String type; |
| | | //2021å¹´6æ11æ¥ 12:13:00 æ·»å |
| | | private String sessionId; |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.fzzy.igds.iot.server; |
| | | |
| | | import com.fzzy.igds.iot.analysis.AnalysisService; |
| | | import com.fzzy.igds.iot.analysis.builder.ReMessageBuilder; |
| | | import com.ld.io.api.IoMsgConsumer; |
| | | import com.ld.io.api.IoSession; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | | * @Description FZZT-IOT æ¶æ¯æ¥æ¶ç±» |
| | | * @Author CZT |
| | | * @Date 2025/11/11 18:17 |
| | | */ |
| | | @Service |
| | | @Slf4j |
| | | public class IotMessageConsumer implements IoMsgConsumer { |
| | | |
| | | @Autowired |
| | | private AnalysisService analysisService; |
| | | |
| | | /** |
| | | * éåéé¢å¤çæ¶æ¯ |
| | | * @param ioSession |
| | | * @param bytes |
| | | */ |
| | | public void consume(IoSession ioSession, byte[] bytes) { |
| | | if (null == bytes) { |
| | | log.error("Reply bytes is null"); |
| | | return; |
| | | } |
| | | try { |
| | | String message = new String(bytes, ReMessageBuilder.CHARSET); |
| | | message = message.substring(ReMessageBuilder.PREFIX.length()); |
| | | log.info("æ¶å°IOTç½å
³æ¶æ¯ï¼" + message); |
| | | analysisService.analysis(ioSession.getBusinessKey(),message); |
| | | }catch (Exception e){ |
| | | log.error(e.getMessage(),e); |
| | | } |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.fzzy.igds.iot.server; |
| | | |
| | | import com.fzzy.igds.iot.analysis.builder.ReMessageBuilder; |
| | | import com.ld.io.api.IoServerOption; |
| | | import com.ld.io.api.IoSession; |
| | | import com.ld.io.api.IoSessionQuery; |
| | | import com.ld.io.netty.NettyServer; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | | * @Description FZZT-IOT æå¡å¯å¨ç±» |
| | | * @Author CZT |
| | | * @Date 2025/11/11 18:09 |
| | | */ |
| | | @Slf4j |
| | | @Service |
| | | public class IotServerEngine { |
| | | |
| | | public static final Integer PORT = 9302; |
| | | |
| | | @Autowired |
| | | private IotMessageConsumer defaultMessageConsumer; |
| | | @Autowired |
| | | private IotSessionListener defaultSessionListener; |
| | | |
| | | private IoSessionQuery sessionQuery; |
| | | |
| | | public void start(Integer port) { |
| | | IoServerOption ioServerOption = new IoServerOption(); |
| | | |
| | | if (null != port) { |
| | | ioServerOption.setPort(port); |
| | | } else { |
| | | ioServerOption.setPort(PORT); |
| | | } |
| | | |
| | | ioServerOption.setDelimiter(ReMessageBuilder.SUFFIX.getBytes()); |
| | | |
| | | NettyServer ioServer = new NettyServer(ioServerOption, defaultMessageConsumer, defaultSessionListener); |
| | | ioServer.startup(); |
| | | |
| | | sessionQuery = ioServer.getSessionQuery(); |
| | | log.info("* "); |
| | | log.info("* ========================"); |
| | | log.info("* "); |
| | | log.info("* [SERVERï¼FZZY_IOT,PORT={}]", PORT); |
| | | log.info("* "); |
| | | log.info("* ========================"); |
| | | log.info("* "); |
| | | |
| | | System.out.println("* ========================"); |
| | | System.out.println("* "); |
| | | System.out.println("* [SERVERï¼FZZY_IOT,PORT={}]" + port); |
| | | System.out.println("* "); |
| | | System.out.println("* ========================"); |
| | | } |
| | | |
| | | public IoSessionQuery getSessionQuery() { |
| | | return sessionQuery; |
| | | } |
| | | |
| | | public IoSession getSessionById(String sessionId) { |
| | | return this.getSessionQuery().getSession(sessionId); |
| | | } |
| | | |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.fzzy.igds.iot.server; |
| | | |
| | | |
| | | import com.fzzy.igds.io.notify.ServerNotifyInvoker; |
| | | import com.fzzy.igds.utils.SpringUtil; |
| | | import com.ld.io.api.IoSession; |
| | | import com.ld.io.api.IoSessionListener; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | | * @Description |
| | | * @Author CZT |
| | | * @Date 2025/11/11 18:09 |
| | | */ |
| | | @Slf4j |
| | | @Service |
| | | public class IotSessionListener implements IoSessionListener { |
| | | private ServerNotifyInvoker serverNotifyInvoker; |
| | | |
| | | @Override |
| | | public void onCreate(IoSession session) { |
| | | |
| | | log.info("++++æ°å»ºè¿æ¥++++-IP={}ï¼PORT={}", session.getAddress(), session.getPort()); |
| | | |
| | | // æ·»å èªå®ä¹ä¸å¡ID |
| | | session.setBusinessKey(ServerUtils.getServerKey(session.getAddress(), session.getPort())); |
| | | } |
| | | |
| | | @Override |
| | | public void onDestroy(IoSession session) { |
| | | log.info("----è¿æ¥æå¼-----IP={}ï¼PORT={}", session.getAddress(), session.getPort()); |
| | | |
| | | if (null == serverNotifyInvoker) { |
| | | serverNotifyInvoker = SpringUtil.getBean(ServerNotifyInvoker.class); |
| | | } |
| | | serverNotifyInvoker.connectDestory(session.getBusinessKey(), |
| | | session.getAddress(), session.getPort()); |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.fzzy.igds.iot.server; |
| | | |
| | | /** |
| | | * @Description å·¥å
·ç±» |
| | | * @Author CZT |
| | | * @Date 2025/11/11 18:07 |
| | | */ |
| | | public class ServerUtils { |
| | | |
| | | |
| | | /** |
| | | * çæTCPè¿æ¥çKEY |
| | | * |
| | | * @param ip |
| | | * @param port |
| | | * @return |
| | | */ |
| | | public static String getServerKey(String ip, Integer port) { |
| | | return ip + ":" + port; |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | import com.fzzy.igds.domain.FileInfo; |
| | | import com.fzzy.igds.domain.Quantity; |
| | | import com.fzzy.igds.domain.QuantityConf; |
| | | import com.fzzy.igds.notify.NotifyWebInvoker; |
| | | import com.fzzy.igds.io.notify.NotifyWebInvoker; |
| | | import com.fzzy.igds.quantity.command.BhznRemoteQuantityImpl; |
| | | import com.fzzy.igds.quantity.command.CommandBuilder; |
| | | import com.fzzy.igds.quantity.dto.IoMessage; |
| | |
| | | quantityData.setDeptId(depot.getDeptId()); |
| | | quantityData.setCompanyId(depot.getCompanyId()); |
| | | quantityData.setPoints(""); |
| | | quantityData.setCheckUser(request.getExeUser()); |
| | | quantityService.saveData(quantityData); |
| | | //ç´æ¥è¿å |
| | | remoteQuantity.sendMsg(ip, port, CommandBuilder.getInstance().build2004Message(message)); |
| | |
| | | import com.fzzy.igds.constant.OrderRespEnum; |
| | | import com.fzzy.igds.constant.ProtocolEnum; |
| | | import com.fzzy.igds.io.service.RemoteQuantityService; |
| | | import com.fzzy.igds.notify.NotifyWebInvoker; |
| | | import com.fzzy.igds.io.notify.NotifyWebInvoker; |
| | | import com.fzzy.igds.quantity.dto.IoMessage; |
| | | import com.fzzy.igds.quantity.server.BhznQuantityServerEngine; |
| | | import com.fzzy.igds.quantity.util.ServerUtils; |
| | |
| | | </Children> |
| | | </FieldSet> |
| | | <FieldSet layout="padding:5"> |
| | | <Property name="caption">è´¨æ£ä¿¡æ¯</Property> |
| | | <Property name="caption">å
¶ä»ä¿¡æ¯</Property> |
| | | <Buttons/> |
| | | <Children> |
| | | <AutoForm> |
| | |
| | | <Property name="labelSeparator"> : </Property> |
| | | <Property name="labelAlign">right</Property> |
| | | <Property name="cols">*,*,*,*,*,*,*,*</Property> |
| | | <Property name="labelWidth">80</Property> |
| | | <Property name="labelWidth">100</Property> |
| | | <AutoFormElement layoutConstraint="colSpan:2"> |
| | | <Property name="name">length</Property> |
| | | <Property name="property">length</Property> |
| | | <Editor/> |
| | | </AutoFormElement> |
| | | <AutoFormElement layoutConstraint="colSpan:2"> |
| | | <Property name="name">width</Property> |
| | | <Property name="property">width</Property> |
| | | <Editor/> |
| | | </AutoFormElement> |
| | | <AutoFormElement layoutConstraint="colSpan:2"> |
| | | <Property name="name">height</Property> |
| | | <Property name="property">height</Property> |
| | | <Editor/> |
| | | </AutoFormElement> |
| | | <AutoFormElement layoutConstraint="colSpan:2"> |
| | | <Property name="name">bulkWeight</Property> |
| | | <Property name="property">bulkWeight</Property> |
| | | <Editor/> |
| | | </AutoFormElement> |
| | | <AutoFormElement layoutConstraint="colSpan:2"> |
| | | <Property name="name">perWet</Property> |
| | | <Property name="property">perWet</Property> |
| | |
| | | <AutoFormElement layoutConstraint="colSpan:2"> |
| | | <Property name="name">perImpurity</Property> |
| | | <Property name="property">perImpurity</Property> |
| | | <Editor/> |
| | | </AutoFormElement> |
| | | <AutoFormElement layoutConstraint="colSpan:2"> |
| | | <Property name="name">bulkWeight</Property> |
| | | <Property name="property">bulkWeight</Property> |
| | | <Editor/> |
| | | </AutoFormElement> |
| | | <AutoFormElement layoutConstraint="colSpan:2"> |
| | |
| | | <Editor/> |
| | | </AutoFormElement> |
| | | <AutoFormElement> |
| | | <Property name="property">diameter</Property> |
| | | <Property name="name">diameter</Property> |
| | | <Editor/> |
| | | </AutoFormElement> |
| | | <AutoFormElement> |
| | | <Property name="property">height</Property> |
| | | <Property name="name">height</Property> |
| | | <Editor/> |
| | | </AutoFormElement> |
| | | <AutoFormElement> |
| | | <Property name="name">updateBy</Property> |
| | | <Property name="property">updateBy</Property> |
| | | <Editor/> |
| | | </AutoFormElement> |
| | | <AutoFormElement> |
| | | <Property name="name">grainFreq</Property> |
| | | <Property name="property">grainFreq</Property> |
| | | <Editor/> |
| | |
| | | <ClientEvent name="onHide">view.id("dsDeviceIot").getData().cancel();</ClientEvent> |
| | | <Property name="iconClass">fa fa-tasks</Property> |
| | | <Property name="caption">设å¤ä¿¡æ¯</Property> |
| | | <Property name="width">35%</Property> |
| | | <Property name="width">60%</Property> |
| | | <Buttons> |
| | | <Button> |
| | | <Property name="action">actionDeviceIotSave</Property> |
| | |
| | | <PropertyDef name="bulkWeight"> |
| | | <Property name="dataType">Double</Property> |
| | | <Property name="label">容é</Property> |
| | | <Property name="displayFormat">0.0 g/L</Property> |
| | | <Property name="displayFormat">#0.00 g/L</Property> |
| | | </PropertyDef> |
| | | <PropertyDef name="length"> |
| | | <Property name="dataType">Double</Property> |
| | | <Property name="label">é¿åº¦/ç´å¾</Property> |
| | | <Property name="displayFormat">#0.00 ç±³</Property> |
| | | </PropertyDef> |
| | | <PropertyDef name="width"> |
| | | <Property name="dataType">Double</Property> |
| | | <Property name="label">宽度</Property> |
| | | <Property name="displayFormat">#0.00 ç±³</Property> |
| | | </PropertyDef> |
| | | <PropertyDef name="height"> |
| | | <Property name="dataType">Double</Property> |
| | | <Property name="label">é«åº¦</Property> |
| | | <Property name="displayFormat">#0.00 ç±³</Property> |
| | | </PropertyDef> |
| | | <PropertyDef name="storeKeeper"> |
| | | <Property></Property> |
| | |
| | | <PropertyDef name="startRow"> |
| | | <Property name="dataType">Integer</Property> |
| | | <Property name="label">èµ·å§æ ¹å·</Property> |
| | | </PropertyDef> |
| | | <PropertyDef name="diameter"> |
| | | <Property name="dataType">Double</Property> |
| | | <Property name="label">çä»ç´å¾</Property> |
| | | <Property name="displayFormat">#0.00 ç±³</Property> |
| | | </PropertyDef> |
| | | <PropertyDef name="height"> |
| | | <Property name="dataType">Double</Property> |
| | | <Property name="label">çä»é«åº¦</Property> |
| | | <Property name="displayFormat">#0.00 ç±³</Property> |
| | | </PropertyDef> |
| | | <PropertyDef name="grainAuto"> |
| | | <Property></Property> |