├── src ├── main │ ├── resources │ │ ├── static │ │ │ ├── img │ │ │ │ ├── angle.png │ │ │ │ ├── login.jpg │ │ │ │ └── favicon.ico │ │ │ └── js │ │ │ │ ├── sys │ │ │ │ ├── help │ │ │ │ │ └── document.js │ │ │ │ └── index.js │ │ │ │ └── login.js │ │ ├── templates │ │ │ ├── common │ │ │ │ ├── momentjs.html │ │ │ │ ├── multi-select.html │ │ │ │ ├── bootstrap-select.html │ │ │ │ ├── bootstrap-daterangepicker.html │ │ │ │ ├── bootstrap-table.html │ │ │ │ ├── echarts.html │ │ │ │ ├── standard.html │ │ │ │ └── topNav.html │ │ │ ├── systemplate.html │ │ │ ├── error.html │ │ │ ├── login.html │ │ │ └── sys │ │ │ │ ├── help │ │ │ │ └── document.html │ │ │ │ ├── memo │ │ │ │ └── memo.html │ │ │ │ └── index.html │ │ ├── config │ │ │ ├── mybatis-config.xml │ │ │ └── shiro-ehcache.xml │ │ └── mapper │ │ │ ├── EndDeviceMapper.xml │ │ │ ├── CropMapper.xml │ │ │ ├── FieldStatusMapper.xml │ │ │ ├── IrrigationPlanMapper.xml │ │ │ ├── SectionMapper.xml │ │ │ ├── MemoMapper.xml │ │ │ ├── DataTypeMapper.xml │ │ │ ├── AlarmRecordMapper.xml │ │ │ ├── BlockMapper.xml │ │ │ ├── FieldMapper.xml │ │ │ ├── UpstreamDataRecordMapper.xml │ │ │ └── MachineMapper.xml │ └── java │ │ └── com │ │ └── njfu │ │ └── ia │ │ ├── sys │ │ ├── service │ │ │ ├── InformService.java │ │ │ ├── EndDeviceService.java │ │ │ ├── impl │ │ │ │ ├── InformServiceImpl.java │ │ │ │ ├── EndDeviceServiceImpl.java │ │ │ │ ├── CropServiceImpl.java │ │ │ │ ├── SectionServiceImpl.java │ │ │ │ ├── FieldServiceImpl.java │ │ │ │ ├── DataTypeServiceImpl.java │ │ │ │ ├── IrrigationPlanServiceImpl.java │ │ │ │ ├── BlockServiceImpl.java │ │ │ │ ├── SensorServiceImpl.java │ │ │ │ ├── AlarmRecordServiceImpl.java │ │ │ │ └── MachineServiceImpl.java │ │ │ ├── CropService.java │ │ │ ├── FieldService.java │ │ │ ├── SectionService.java │ │ │ ├── DataTypeService.java │ │ │ ├── BlockService.java │ │ │ ├── AlarmRecordService.java │ │ │ ├── IrrigationPlanService.java │ │ │ ├── UpstreamDataRecordService.java │ │ │ ├── MachineService.java │ │ │ ├── SensorService.java │ │ │ └── MemoService.java │ │ ├── exception │ │ │ └── BusinessException.java │ │ ├── utils │ │ │ ├── page │ │ │ │ ├── PageOffset.java │ │ │ │ └── PageAspect.java │ │ │ ├── PaginationResult.java │ │ │ ├── JsonUtils.java │ │ │ └── Result.java │ │ ├── mapper │ │ │ ├── EndDeviceMapper.java │ │ │ ├── CropMapper.java │ │ │ ├── DataTypeMapper.java │ │ │ ├── SectionMapper.java │ │ │ ├── FieldMapper.java │ │ │ ├── AlarmRecordMapper.java │ │ │ ├── BlockMapper.java │ │ │ ├── IrrigationPlanMapper.java │ │ │ ├── MemoMapper.java │ │ │ ├── MachineMapper.java │ │ │ ├── SensorMapper.java │ │ │ └── UpstreamDataRecordMapper.java │ │ ├── web │ │ │ ├── HelpController.java │ │ │ ├── ExceptionController.java │ │ │ ├── IndexController.java │ │ │ └── SecurityController.java │ │ ├── domain │ │ │ ├── Role.java │ │ │ ├── Crop.java │ │ │ ├── IrrigationPlan.java │ │ │ ├── ChartData.java │ │ │ ├── InformRet.java │ │ │ ├── Section.java │ │ │ ├── Permission.java │ │ │ ├── Block.java │ │ │ ├── Machine.java │ │ │ ├── Field.java │ │ │ ├── DataType.java │ │ │ ├── Memo.java │ │ │ ├── User.java │ │ │ ├── Sensor.java │ │ │ └── EndDevice.java │ │ ├── enums │ │ │ └── ResultEnum.java │ │ ├── websocket │ │ │ └── TipWebSocketConfig.java │ │ └── mail │ │ │ └── MailSender.java │ │ └── IAApplication.java └── test │ └── java │ └── com │ └── njfu │ └── ia │ ├── sys │ ├── mapper │ │ ├── SectionMapperTest.java │ │ ├── EndDeviceMapperTest.java │ │ ├── CropMapperTest.java │ │ ├── FieldMapperTest.java │ │ ├── BlockMapperTest.java │ │ ├── MemoMapperTest.java │ │ └── IrrigationPlanMapperTest.java │ └── service │ │ ├── SectionServiceTest.java │ │ ├── UpstreamDataRecordServiceTest.java │ │ ├── CropServiceTest.java │ │ ├── FieldServiceTest.java │ │ ├── BlockServiceTest.java │ │ ├── MemoServiceTest.java │ │ ├── IrrigationPlanServiceTest.java │ │ ├── SensorServiceTest.java │ │ └── MachineServiceTest.java │ └── test │ └── SimpleTest.java ├── .gitignore ├── IA-PCS └── src │ ├── test │ └── java │ │ └── com │ │ └── njfu │ │ └── ia │ │ └── process │ │ ├── MyTest.java │ │ └── redis │ │ └── RedisConfigTest.java │ └── main │ ├── java │ └── com │ │ └── njfu │ │ └── ia │ │ ├── process │ │ ├── service │ │ │ └── UpstreamService.java │ │ ├── exception │ │ │ └── BusinessException.java │ │ ├── mapper │ │ │ ├── AlarmRecordMapper.java │ │ │ ├── DataTypeMapper.java │ │ │ ├── UpstreamDataRecordMapper.java │ │ │ └── EndDeviceMapper.java │ │ ├── domain │ │ │ ├── UpstreamRet.java │ │ │ ├── InformRet.java │ │ │ ├── Section.java │ │ │ ├── DownstreamRet.java │ │ │ ├── UpstreamDataRecord.java │ │ │ ├── DataType.java │ │ │ ├── AlarmRecord.java │ │ │ └── EndDevice.java │ │ ├── jms │ │ │ ├── consumer │ │ │ │ ├── handler │ │ │ │ │ ├── UpstreamHandler.java │ │ │ │ │ ├── HeartUpstreamHandler.java │ │ │ │ │ └── OnUpstreamHandler.java │ │ │ │ ├── UpstreamOnAndHeartMessageConsumer.java │ │ │ │ └── UpstreamDataMessageConsumer.java │ │ │ ├── DestinationConfig.java │ │ │ └── JmsSender.java │ │ └── utils │ │ │ └── JsonUtils.java │ │ └── ProcessApplication.java │ └── resources │ ├── config │ └── mybatis-config.xml │ └── mapper │ ├── AlarmRecordMapper.xml │ ├── DataTypeMapper.xml │ ├── UploadDataRecordMapper.xml │ └── EndDeviceMapper.xml └── IA-LSN └── src ├── main ├── java │ └── com │ │ └── njfu │ │ └── ia │ │ └── listener │ │ ├── domain │ │ ├── DownstreamRet.java │ │ └── UpstreamRet.java │ │ ├── Listener.java │ │ ├── utils │ │ └── JsonUtils.java │ │ ├── jms │ │ └── DownstreamMessageListener.java │ │ └── connection │ │ └── Connections.java └── resources │ └── logback.xml └── test └── java └── com └── njfu └── ia └── listener └── SocketTest.java /src/main/resources/static/img/angle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wch853/ia/HEAD/src/main/resources/static/img/angle.png -------------------------------------------------------------------------------- /src/main/resources/static/img/login.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wch853/ia/HEAD/src/main/resources/static/img/login.jpg -------------------------------------------------------------------------------- /src/main/resources/static/img/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wch853/ia/HEAD/src/main/resources/static/img/favicon.ico -------------------------------------------------------------------------------- /src/main/resources/static/js/sys/help/document.js: -------------------------------------------------------------------------------- 1 | // 激活侧边栏 2 | $('[data-target="#help-man"]').trigger('click').parent().find('li:eq(0) a').addClass('side-active'); 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # classes 2 | target/ 3 | 4 | # log 5 | log/ 6 | 7 | # properties 8 | application.yml 9 | 10 | ### IntelliJ IDEA ### 11 | .idea 12 | *.iws 13 | *.iml 14 | *.ipr 15 | -------------------------------------------------------------------------------- /src/main/resources/templates/common/momentjs.html: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /src/main/resources/templates/common/multi-select.html: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /IA-PCS/src/test/java/com/njfu/ia/process/MyTest.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.process; 2 | 3 | import org.junit.Test; 4 | 5 | public class MyTest { 6 | 7 | @Test 8 | public void test1() { 9 | String[] x = "abc|".split("\\|"); 10 | System.out.println(x.length); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /IA-PCS/src/main/java/com/njfu/ia/process/service/UpstreamService.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.process.service; 2 | 3 | /** 4 | * 数据上行服务 5 | */ 6 | public interface UpstreamService { 7 | 8 | /** 9 | * 消费上行消息 10 | * 11 | * @param message messageText 12 | */ 13 | void consumeUpstreamMessage(String message); 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/njfu/ia/sys/service/InformService.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.sys.service; 2 | 3 | import com.njfu.ia.sys.domain.InformRet; 4 | 5 | public interface InformService { 6 | 7 | /** 8 | * 处理上行通知报文 9 | * 10 | * @param informRet 11 | */ 12 | void consumeInfromRet(InformRet informRet); 13 | } 14 | -------------------------------------------------------------------------------- /src/main/resources/templates/common/bootstrap-select.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /src/main/resources/templates/common/bootstrap-daterangepicker.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/main/resources/templates/common/bootstrap-table.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/main/java/com/njfu/ia/IAApplication.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class IAApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(IAApplication.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /IA-PCS/src/main/java/com/njfu/ia/ProcessApplication.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class ProcessApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(ProcessApplication.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/com/njfu/ia/sys/service/EndDeviceService.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.sys.service; 2 | 3 | import com.njfu.ia.sys.domain.EndDevice; 4 | 5 | import java.util.List; 6 | 7 | public interface EndDeviceService { 8 | 9 | /** 10 | * 查询终端设备信息 11 | * 12 | * @param endDevice 13 | * @return 14 | */ 15 | List queryEndDevices(EndDevice endDevice); 16 | } 17 | -------------------------------------------------------------------------------- /IA-PCS/src/main/java/com/njfu/ia/process/exception/BusinessException.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.process.exception; 2 | 3 | /** 4 | * 自定义业务异常 5 | */ 6 | public class BusinessException extends RuntimeException { 7 | 8 | public BusinessException(String message) { 9 | super(message); 10 | } 11 | 12 | public BusinessException(String message, Throwable cause) { 13 | super(message, cause); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/com/njfu/ia/sys/exception/BusinessException.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.sys.exception; 2 | 3 | /** 4 | * 自定义业务异常 5 | */ 6 | public class BusinessException extends RuntimeException { 7 | 8 | public BusinessException(String message) { 9 | super(message); 10 | } 11 | 12 | public BusinessException(String message, Throwable cause) { 13 | super(message, cause); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/com/njfu/ia/sys/utils/page/PageOffset.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.sys.utils.page; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * 用于标注在需要分页的路由方法上 10 | */ 11 | @Retention(RetentionPolicy.RUNTIME) 12 | @Target(ElementType.METHOD) 13 | public @interface PageOffset { 14 | } 15 | -------------------------------------------------------------------------------- /IA-PCS/src/main/java/com/njfu/ia/process/mapper/AlarmRecordMapper.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.process.mapper; 2 | 3 | import com.njfu.ia.process.domain.AlarmRecord; 4 | import org.apache.ibatis.annotations.Mapper; 5 | 6 | @Mapper 7 | public interface AlarmRecordMapper { 8 | 9 | /** 10 | * 新增报警数据 11 | * 12 | * @param record record 13 | * @return count 14 | */ 15 | int insertAlarmRecord(AlarmRecord record); 16 | } 17 | -------------------------------------------------------------------------------- /IA-PCS/src/main/resources/config/mybatis-config.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/main/resources/config/mybatis-config.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/main/java/com/njfu/ia/sys/mapper/EndDeviceMapper.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.sys.mapper; 2 | 3 | import com.njfu.ia.sys.domain.EndDevice; 4 | import org.apache.ibatis.annotations.Mapper; 5 | 6 | import java.util.List; 7 | 8 | @Mapper 9 | public interface EndDeviceMapper { 10 | 11 | /** 12 | * 查询终端设备信息 13 | * 14 | * @param endDevice 15 | * @return 16 | */ 17 | List selectEndDevices(EndDevice endDevice); 18 | 19 | } 20 | -------------------------------------------------------------------------------- /IA-PCS/src/main/java/com/njfu/ia/process/mapper/DataTypeMapper.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.process.mapper; 2 | 3 | import com.njfu.ia.process.domain.DataType; 4 | import org.apache.ibatis.annotations.Mapper; 5 | 6 | import java.util.List; 7 | 8 | @Mapper 9 | public interface DataTypeMapper { 10 | 11 | /** 12 | * 查询所有数据类型 13 | * 14 | * @param dataType dataType 15 | * @return return 16 | */ 17 | List selectDataTypes(DataType dataType); 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/njfu/ia/sys/web/HelpController.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.sys.web; 2 | 3 | import org.springframework.stereotype.Controller; 4 | import org.springframework.web.bind.annotation.RequestMapping; 5 | 6 | @Controller 7 | @RequestMapping("/sys/help") 8 | public class HelpController { 9 | 10 | /** 11 | * 帮助文档页 12 | * 13 | * @return Page 14 | */ 15 | @RequestMapping("") 16 | public String document() { 17 | return "sys/help/document"; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /IA-PCS/src/main/resources/mapper/AlarmRecordMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | INSERT INTO alarm_record (device_id, data_type, value, alarm_time) 10 | VALUES (#{deviceId}, #{dataType}, #{value}, #{alarmTime}) 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/main/java/com/njfu/ia/sys/service/impl/InformServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.sys.service.impl; 2 | 3 | import com.njfu.ia.sys.domain.InformRet; 4 | import com.njfu.ia.sys.service.InformService; 5 | import org.springframework.stereotype.Service; 6 | 7 | @Service 8 | public class InformServiceImpl implements InformService { 9 | 10 | /** 11 | * 处理上行通知报文 12 | * 13 | * @param informRet 14 | */ 15 | @Override 16 | public void consumeInfromRet(InformRet informRet) { 17 | 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /IA-PCS/src/main/resources/mapper/DataTypeMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 17 | 18 | -------------------------------------------------------------------------------- /IA-PCS/src/test/java/com/njfu/ia/process/redis/RedisConfigTest.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.process.redis; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | import java.io.IOException; 9 | 10 | @RunWith(SpringRunner.class) 11 | @SpringBootTest 12 | public class RedisConfigTest { 13 | 14 | @Test 15 | public void redisTest1() { 16 | try { 17 | System.in.read(); 18 | } catch (IOException e) { 19 | e.printStackTrace(); 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /src/main/resources/config/shiro-ehcache.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 12 | -------------------------------------------------------------------------------- /src/main/java/com/njfu/ia/sys/domain/Role.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.sys.domain; 2 | 3 | /** 4 | * 角色 5 | */ 6 | public class Role { 7 | 8 | /** 9 | * 角色编号 10 | */ 11 | private Integer id; 12 | 13 | /** 14 | * 角色名称 15 | */ 16 | private String roleName; 17 | 18 | public Integer getId() { 19 | return id; 20 | } 21 | 22 | public void setId(Integer id) { 23 | this.id = id; 24 | } 25 | 26 | public String getRoleName() { 27 | return roleName; 28 | } 29 | 30 | public void setRoleName(String roleName) { 31 | this.roleName = roleName; 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/com/njfu/ia/sys/domain/Crop.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.sys.domain; 2 | 3 | /** 4 | * 作物 5 | */ 6 | public class Crop { 7 | 8 | /** 9 | * 作物编号 10 | */ 11 | private Integer Id; 12 | 13 | /** 14 | * 作物名称 15 | */ 16 | private String cropName; 17 | 18 | public Crop() { 19 | } 20 | 21 | public Integer getId() { 22 | return Id; 23 | } 24 | 25 | public void setId(Integer id) { 26 | Id = id; 27 | } 28 | 29 | public String getCropName() { 30 | return cropName; 31 | } 32 | 33 | public void setCropName(String cropName) { 34 | this.cropName = cropName; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/njfu/ia/sys/service/CropService.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.sys.service; 2 | 3 | import com.njfu.ia.sys.domain.Crop; 4 | 5 | import java.util.List; 6 | 7 | public interface CropService { 8 | 9 | /** 10 | * 获取作物列表 11 | * 12 | * @param crop 13 | * @return 14 | */ 15 | List queryCrops(Crop crop); 16 | 17 | /** 18 | * 新增作物信息 19 | * 20 | * @param crop 21 | */ 22 | void addCrop(Crop crop); 23 | 24 | /** 25 | * 修改作物信息 26 | * 27 | * @param crop 28 | */ 29 | void modifyCrop(Crop crop); 30 | 31 | /** 32 | * 删除作物信息 33 | * 34 | * @param crop 35 | */ 36 | void removeCrop(Crop crop); 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/njfu/ia/sys/service/FieldService.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.sys.service; 2 | 3 | import com.njfu.ia.sys.domain.Field; 4 | 5 | import java.util.List; 6 | 7 | public interface FieldService { 8 | 9 | /** 10 | * 查询大棚信息 11 | * 12 | * @param field 13 | * @return 14 | */ 15 | List queryFields(Field field); 16 | 17 | /** 18 | * 新增大棚信息 19 | * 20 | * @param field 21 | */ 22 | void addField(Field field); 23 | 24 | /** 25 | * 修改大棚信息 26 | * 27 | * @param field 28 | */ 29 | void modifyField(Field field); 30 | 31 | /** 32 | * 删除大棚信息 33 | * 34 | * @param id 35 | */ 36 | void removeField(Integer id); 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/njfu/ia/sys/service/SectionService.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.sys.service; 2 | 3 | import com.njfu.ia.sys.domain.Section; 4 | 5 | import java.util.List; 6 | 7 | public interface SectionService { 8 | 9 | /** 10 | * 查询区块信息 11 | * 12 | * @param section 13 | * @return 14 | */ 15 | List
querySections(Section section); 16 | 17 | /** 18 | * 新增区块信息 19 | * 20 | * @param section 21 | */ 22 | void addSection(Section section); 23 | 24 | /** 25 | * 修改区块信息 26 | * 27 | * @param section 28 | */ 29 | void modifySection(Section section); 30 | 31 | /** 32 | * 删除区块信息 33 | * 34 | * @param id 35 | */ 36 | void removeSection(Integer id); 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/njfu/ia/sys/service/DataTypeService.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.sys.service; 2 | 3 | import com.njfu.ia.sys.domain.DataType; 4 | 5 | import java.util.List; 6 | 7 | public interface DataTypeService { 8 | 9 | /** 10 | * 查询数据类型 11 | * 12 | * @param 13 | * @return 14 | */ 15 | List queryDataTypes(DataType dataType); 16 | 17 | /** 18 | * 新增数据类型 19 | * 20 | * @param dataType 21 | */ 22 | void addDataType(DataType dataType); 23 | 24 | /** 25 | * 更新数据类型 26 | * 27 | * @param dataType 28 | */ 29 | void updateDataType(DataType dataType); 30 | 31 | /** 32 | * 删除数据类型 33 | * 34 | * @param id 35 | */ 36 | void reomveDataType(Integer id); 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/njfu/ia/sys/service/impl/EndDeviceServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.sys.service.impl; 2 | 3 | import com.njfu.ia.sys.domain.EndDevice; 4 | import com.njfu.ia.sys.mapper.EndDeviceMapper; 5 | import com.njfu.ia.sys.service.EndDeviceService; 6 | import org.springframework.stereotype.Service; 7 | 8 | import javax.annotation.Resource; 9 | import java.util.List; 10 | 11 | @Service 12 | public class EndDeviceServiceImpl implements EndDeviceService { 13 | 14 | @Resource 15 | private EndDeviceMapper endDeviceMapper; 16 | 17 | /** 18 | * 查询终端设备信息 19 | * 20 | * @param endDevice 21 | * @return 22 | */ 23 | @Override 24 | public List queryEndDevices(EndDevice endDevice) { 25 | return endDeviceMapper.selectEndDevices(endDevice); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /IA-LSN/src/main/java/com/njfu/ia/listener/domain/DownstreamRet.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.listener.domain; 2 | 3 | import com.fasterxml.jackson.annotation.JsonFormat; 4 | 5 | import java.util.Date; 6 | 7 | /** 8 | * 下行数据报文 9 | */ 10 | public class DownstreamRet { 11 | 12 | /** 13 | * 发送时间 14 | */ 15 | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") 16 | private Date sendTime; 17 | 18 | /** 19 | * 数据内容 20 | */ 21 | private String data; 22 | 23 | public Date getSendTime() { 24 | return sendTime; 25 | } 26 | 27 | public void setSendTime(Date sendTime) { 28 | this.sendTime = sendTime; 29 | } 30 | 31 | public String getData() { 32 | return data; 33 | } 34 | 35 | public void setData(String data) { 36 | this.data = data; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/com/njfu/ia/sys/enums/ResultEnum.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.sys.enums; 2 | 3 | /** 4 | * 存放结果代码 5 | */ 6 | public enum ResultEnum { 7 | 8 | /** 9 | * 成功 10 | */ 11 | SUCCESS(200), 12 | 13 | /** 14 | * 数据 15 | */ 16 | DATA(201), 17 | 18 | /** 19 | * 警告数据 20 | */ 21 | WARN(202), 22 | 23 | /** 24 | * 失败 25 | */ 26 | FAIL(300), 27 | 28 | /** 29 | * 非法数据请求 30 | */ 31 | BAD_REQUEST(400), 32 | 33 | /** 34 | * 无权限 35 | */ 36 | UNAUTHORIZED(403); 37 | 38 | /** 39 | * 结果代码 40 | */ 41 | private Integer code; 42 | 43 | ResultEnum(Integer code) { 44 | this.code = code; 45 | } 46 | 47 | public Integer code() { 48 | return code; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/com/njfu/ia/sys/mapper/CropMapper.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.sys.mapper; 2 | 3 | import com.njfu.ia.sys.domain.Crop; 4 | import org.apache.ibatis.annotations.Mapper; 5 | 6 | import java.util.List; 7 | 8 | @Mapper 9 | public interface CropMapper { 10 | 11 | /** 12 | * 获取作物列表 13 | * 14 | * @param crop 15 | * @return 16 | */ 17 | List selectCrops(Crop crop); 18 | 19 | /** 20 | * 新增作物信息 21 | * 22 | * @param crop 23 | * @return 24 | */ 25 | int insertCrop(Crop crop); 26 | 27 | /** 28 | * 修改作物信息 29 | * 30 | * @param crop 31 | * @return 32 | */ 33 | int updateCrop(Crop crop); 34 | 35 | /** 36 | * 删除作物信息 37 | * 38 | * @param crop 39 | * @return 40 | */ 41 | int deleteCrop(Crop crop); 42 | } 43 | -------------------------------------------------------------------------------- /IA-PCS/src/main/java/com/njfu/ia/process/domain/UpstreamRet.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.process.domain; 2 | 3 | import java.util.Date; 4 | 5 | /** 6 | * 上行报文 7 | */ 8 | public class UpstreamRet { 9 | 10 | /** 11 | * 侦听数据获取时间 12 | */ 13 | private Date receiveTime; 14 | 15 | /** 16 | * 数据内容 17 | */ 18 | private String data; 19 | 20 | public UpstreamRet(Date receiveTime, String data) { 21 | this.receiveTime = receiveTime; 22 | this.data = data; 23 | } 24 | 25 | public Date getReceiveTime() { 26 | return receiveTime; 27 | } 28 | 29 | public void setReceiveTime(Date receiveTime) { 30 | this.receiveTime = receiveTime; 31 | } 32 | 33 | public String getData() { 34 | return data; 35 | } 36 | 37 | public void setData(String data) { 38 | this.data = data; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /IA-PCS/src/main/java/com/njfu/ia/process/jms/consumer/handler/UpstreamHandler.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.process.jms.consumer.handler; 2 | 3 | import java.util.Date; 4 | import java.util.Map; 5 | 6 | /** 7 | * 上行数据抽象处理器 8 | */ 9 | public abstract class UpstreamHandler { 10 | 11 | /** 12 | * 数据接收时间 13 | */ 14 | private Date receiveTime; 15 | 16 | /** 17 | * 接收数据内容 18 | */ 19 | private Map retMap; 20 | 21 | public UpstreamHandler(Date receiveTime, Map retMap) { 22 | this.receiveTime = receiveTime; 23 | this.retMap = retMap; 24 | } 25 | 26 | public Date getReceiveTime() { 27 | return receiveTime; 28 | } 29 | 30 | public Map getRetMap() { 31 | return retMap; 32 | } 33 | 34 | /** 35 | * 处理上行数据 36 | */ 37 | public abstract void handleUpstream(); 38 | } 39 | -------------------------------------------------------------------------------- /IA-PCS/src/main/java/com/njfu/ia/process/mapper/UpstreamDataRecordMapper.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.process.mapper; 2 | 3 | import com.njfu.ia.process.domain.UpstreamDataRecord; 4 | import org.apache.ibatis.annotations.Mapper; 5 | import org.apache.ibatis.annotations.Param; 6 | 7 | import java.util.List; 8 | 9 | @Mapper 10 | public interface UpstreamDataRecordMapper { 11 | 12 | /** 13 | * 批量插入上行数据 14 | * 15 | * @param upstreamDataRecords upstreamDataRecords 16 | * @return count 17 | */ 18 | int batchInsertDataRecords(List upstreamDataRecords); 19 | 20 | /** 21 | * 查询指定时间间隔内有数据记录的device id 22 | * 23 | * @param second second 24 | * @param deviceIds deviceIds 25 | * @return device id list 26 | */ 27 | List selectHasRecordDevice(@Param("second") int second, @Param("deviceIds") List deviceIds); 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/com/njfu/ia/sys/service/BlockService.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.sys.service; 2 | 3 | import com.njfu.ia.sys.domain.Block; 4 | 5 | import java.util.List; 6 | 7 | public interface BlockService { 8 | 9 | /** 10 | * 获取地块信息 11 | * 12 | * @param block 13 | * @return 14 | */ 15 | List queryBlocks(Block block); 16 | 17 | /** 18 | * index页获取所有地块信息及相应地块下使用状态的大棚 19 | * 20 | * @return 21 | */ 22 | List queryBlocksWithSections(); 23 | 24 | /** 25 | * 新增地块信息 26 | * 27 | * @param block 28 | */ 29 | void addBlock(Block block); 30 | 31 | /** 32 | * 修改地块信息 33 | * 34 | * @param block 35 | */ 36 | void modifyBlock(Block block); 37 | 38 | /** 39 | * 删除地块信息 40 | * 41 | * @param id 42 | */ 43 | void removeBlock(Integer id); 44 | } -------------------------------------------------------------------------------- /src/main/java/com/njfu/ia/sys/utils/PaginationResult.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.sys.utils; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * 用于返回分页结果 7 | */ 8 | public class PaginationResult { 9 | 10 | /** 11 | * 数据总数 12 | */ 13 | private long total; 14 | 15 | /** 16 | * 返回数据 17 | */ 18 | private List rows; 19 | 20 | public PaginationResult() { 21 | } 22 | 23 | public PaginationResult(long total, List rows) { 24 | this.total = total; 25 | this.rows = rows; 26 | } 27 | 28 | public long getTotal() { 29 | return total; 30 | } 31 | 32 | public void setTotal(long total) { 33 | this.total = total; 34 | } 35 | 36 | public List getRows() { 37 | return rows; 38 | } 39 | 40 | public void setRows(List rows) { 41 | this.rows = rows; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/test/java/com/njfu/ia/sys/mapper/SectionMapperTest.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.sys.mapper; 2 | 3 | import com.njfu.ia.sys.domain.Section; 4 | import org.junit.Test; 5 | import org.junit.runner.RunWith; 6 | import org.slf4j.Logger; 7 | import org.slf4j.LoggerFactory; 8 | import org.springframework.boot.test.context.SpringBootTest; 9 | import org.springframework.test.context.junit4.SpringRunner; 10 | 11 | import javax.annotation.Resource; 12 | import java.util.List; 13 | 14 | @RunWith(SpringRunner.class) 15 | @SpringBootTest 16 | public class SectionMapperTest { 17 | 18 | private static final Logger LOGGER = LoggerFactory.getLogger(SpringBootTest.class); 19 | 20 | @Resource 21 | private SectionMapper sectionMapper; 22 | 23 | @Test 24 | public void selectSections() { 25 | List
sections = sectionMapper.selectSections(new Section()); 26 | LOGGER.info("sections: {}", sections); 27 | } 28 | } -------------------------------------------------------------------------------- /src/main/java/com/njfu/ia/sys/mapper/DataTypeMapper.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.sys.mapper; 2 | 3 | import com.njfu.ia.sys.domain.DataType; 4 | import org.apache.ibatis.annotations.Mapper; 5 | 6 | import java.util.List; 7 | 8 | @Mapper 9 | public interface DataTypeMapper { 10 | 11 | /** 12 | * 查询数据类型 13 | * 14 | * @param dataType 15 | * @return 16 | */ 17 | List selectDataTypes(DataType dataType); 18 | 19 | /** 20 | * 新增数据类型 21 | * 22 | * @param dataType 23 | * @return 24 | */ 25 | int insertDataType(DataType dataType); 26 | 27 | /** 28 | * 更新数据类型 29 | * 30 | * @param dataType 31 | * @return 32 | */ 33 | int updateDataType(DataType dataType); 34 | 35 | /** 36 | * 删除数据类型 37 | * 38 | * @param id 39 | * @return 40 | */ 41 | int deleteDataType(Integer id); 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/com/njfu/ia/sys/mapper/SectionMapper.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.sys.mapper; 2 | 3 | import com.njfu.ia.sys.domain.Section; 4 | import org.apache.ibatis.annotations.Mapper; 5 | import org.apache.ibatis.annotations.Param; 6 | 7 | import java.util.List; 8 | 9 | @Mapper 10 | public interface SectionMapper { 11 | 12 | /** 13 | * 查询区块信息 14 | * 15 | * @param section 16 | * @return 17 | */ 18 | List
selectSections(Section section); 19 | 20 | /** 21 | * 新增区块信息 22 | * 23 | * @param section 24 | * @return 25 | */ 26 | int insertSection(Section section); 27 | 28 | /** 29 | * 修改区块信息 30 | * 31 | * @param section 32 | * @return 33 | */ 34 | int updateSection(Section section); 35 | 36 | /** 37 | * 删除区块信息 38 | * 39 | * @param id 40 | * @return 41 | */ 42 | int deleteSection(@Param("id") Integer id); 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/com/njfu/ia/sys/mapper/FieldMapper.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.sys.mapper; 2 | 3 | import com.njfu.ia.sys.domain.Field; 4 | import org.apache.ibatis.annotations.Mapper; 5 | import org.apache.ibatis.annotations.Param; 6 | 7 | import java.util.List; 8 | 9 | @Mapper 10 | public interface FieldMapper { 11 | 12 | /** 13 | * 获取大棚列表 14 | * 15 | * @param field 16 | * @return 17 | */ 18 | List selectFields(Field field); 19 | 20 | /** 21 | * 新增大棚信息 22 | * 23 | * @param field 24 | * @return 25 | */ 26 | int insertField(Field field); 27 | 28 | /** 29 | * 修改大棚信息 30 | * 31 | * @param field 32 | * @return 33 | */ 34 | int updateField(Field field); 35 | 36 | /** 37 | * 删除大棚信息 38 | * 39 | * @param id 40 | * @return 41 | */ 42 | int deleteField(@Param("id") Integer id); 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/com/njfu/ia/sys/service/AlarmRecordService.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.sys.service; 2 | 3 | import com.njfu.ia.sys.domain.AlarmRecord; 4 | 5 | import java.util.List; 6 | 7 | public interface AlarmRecordService { 8 | 9 | /** 10 | * 查询报警记录 11 | * 12 | * @param alarmRecord 13 | * @param start 14 | * @param end 15 | * @return 16 | */ 17 | List queryAlarmRecords(AlarmRecord alarmRecord, String start, String end); 18 | 19 | /** 20 | * 查询未处理报警记录 21 | * 22 | * @return 23 | */ 24 | List queryUnhandleRecords(); 25 | 26 | /** 27 | * 查询未处理报警记录数量 28 | * 29 | * @return 30 | */ 31 | int queryUnhandleRecordsCount(); 32 | 33 | /** 34 | * 更新报警记录处理状态位 35 | * 36 | * @param ids 37 | * @param flag 38 | */ 39 | void modifyAlarmRecordFlag(Integer[] ids, Integer flag); 40 | } 41 | -------------------------------------------------------------------------------- /src/test/java/com/njfu/ia/sys/service/SectionServiceTest.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.sys.service; 2 | 3 | import com.njfu.ia.sys.domain.Section; 4 | import org.junit.Test; 5 | import org.junit.runner.RunWith; 6 | import org.slf4j.Logger; 7 | import org.slf4j.LoggerFactory; 8 | import org.springframework.boot.test.context.SpringBootTest; 9 | import org.springframework.test.context.junit4.SpringRunner; 10 | 11 | import javax.annotation.Resource; 12 | import java.util.List; 13 | 14 | @RunWith(SpringRunner.class) 15 | @SpringBootTest 16 | public class SectionServiceTest { 17 | 18 | private static final Logger LOGGER = LoggerFactory.getLogger(SectionServiceTest.class); 19 | 20 | @Resource 21 | private SectionService sectionService; 22 | 23 | @Test 24 | public void selectSections() { 25 | List
sections = sectionService.querySections(new Section()); 26 | LOGGER.info("sections: {}", sections); 27 | } 28 | } -------------------------------------------------------------------------------- /src/main/java/com/njfu/ia/sys/service/IrrigationPlanService.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.sys.service; 2 | 3 | import com.njfu.ia.sys.domain.IrrigationPlan; 4 | 5 | import java.util.List; 6 | 7 | public interface IrrigationPlanService { 8 | 9 | /** 10 | * 获取灌溉方案列表 11 | * 12 | * @param irrigationPlan irrigationPlan 13 | * @return IrrigationPlan list 14 | */ 15 | List queryIrrigationPlans(IrrigationPlan irrigationPlan); 16 | 17 | /** 18 | * 新增灌溉方案 19 | * 20 | * @param irrigationPlan irrigationPlan 21 | */ 22 | void addIrrigationPlan(IrrigationPlan irrigationPlan); 23 | 24 | /** 25 | * 修改灌溉方案 26 | * 27 | * @param irrigationPlan irrigationPlan 28 | */ 29 | void modifyIrrigationPlan(IrrigationPlan irrigationPlan); 30 | 31 | /** 32 | * 删除灌溉方案 33 | * 34 | * @param id id 35 | */ 36 | void removeIrrigationPlan(Integer id); 37 | } 38 | -------------------------------------------------------------------------------- /src/main/resources/templates/systemplate.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | <#include "/common/standard.html"/> 6 | 7 | 8 | 9 |
10 | 11 | <#include "/common/topNav.html"/> 12 | 13 | 14 | <#include "/sys/sysSideNav.html"/> 15 | 16 | 17 |
18 |
19 | 22 | 23 |
24 | 28 |
29 |
30 |
31 | 32 |
33 | 34 | 35 | -------------------------------------------------------------------------------- /src/main/java/com/njfu/ia/sys/domain/IrrigationPlan.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.sys.domain; 2 | 3 | /** 4 | * 灌溉方案 5 | */ 6 | public class IrrigationPlan { 7 | 8 | /** 9 | * 方案编号 10 | */ 11 | private Integer id; 12 | 13 | /** 14 | * 灌溉量 15 | */ 16 | private Double planVolume; 17 | 18 | /** 19 | * 持续时长 20 | */ 21 | private Integer duration; 22 | 23 | public Integer getId() { 24 | return id; 25 | } 26 | 27 | public void setId(Integer id) { 28 | this.id = id; 29 | } 30 | 31 | public Double getPlanVolume() { 32 | return planVolume; 33 | } 34 | 35 | public void setPlanVolume(Double planVolume) { 36 | this.planVolume = planVolume; 37 | } 38 | 39 | public Integer getDuration() { 40 | return duration; 41 | } 42 | 43 | public void setDuration(Integer duration) { 44 | this.duration = duration; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/com/njfu/ia/sys/web/ExceptionController.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.sys.web; 2 | 3 | import com.njfu.ia.sys.enums.ResultEnum; 4 | import com.njfu.ia.sys.utils.Result; 5 | import org.slf4j.Logger; 6 | import org.slf4j.LoggerFactory; 7 | import org.springframework.web.bind.annotation.ControllerAdvice; 8 | import org.springframework.web.bind.annotation.ExceptionHandler; 9 | import org.springframework.web.bind.annotation.ResponseBody; 10 | 11 | /** 12 | * 异常控制器 13 | */ 14 | @ControllerAdvice 15 | public class ExceptionController { 16 | 17 | private static final Logger LOGGER = LoggerFactory.getLogger(ExceptionController.class); 18 | 19 | /** 20 | * 统一异常处理 21 | * 22 | * @return json Result 23 | */ 24 | @ExceptionHandler(Exception.class) 25 | public @ResponseBody 26 | Result exceptionHandler(Exception e) { 27 | LOGGER.error(e.getMessage(), e); 28 | return Result.response(ResultEnum.FAIL); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/main/resources/templates/error.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | <#include "/common/standard.html"/> 6 | 错误 7 | 8 | 9 |
10 | 11 | <#include "/common/topNav.html"/> 12 | 13 | 14 | <#include "/sys/sysSideNav.html"/> 15 | 16 | 17 |
18 |
19 |
20 |
21 |

22 | 发生错误 ${status!} 23 |

24 | 返回首页 25 |
26 |
27 |
28 |
29 | 30 |
31 | 32 | -------------------------------------------------------------------------------- /IA-LSN/src/main/java/com/njfu/ia/listener/domain/UpstreamRet.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.listener.domain; 2 | 3 | import com.fasterxml.jackson.annotation.JsonFormat; 4 | 5 | import java.util.Date; 6 | 7 | /** 8 | * 上行数据报文 9 | */ 10 | public class UpstreamRet { 11 | 12 | /** 13 | * 数据接收时间 14 | */ 15 | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") 16 | private Date receiveTime; 17 | 18 | /** 19 | * 数据内容 20 | */ 21 | private String data; 22 | 23 | public UpstreamRet(Date receiveTime, String data) { 24 | this.receiveTime = receiveTime; 25 | this.data = data; 26 | } 27 | 28 | public Date getReceiveTime() { 29 | return receiveTime; 30 | } 31 | 32 | public void setReceiveTime(Date receiveTime) { 33 | this.receiveTime = receiveTime; 34 | } 35 | 36 | public String getData() { 37 | return data; 38 | } 39 | 40 | public void setData(String data) { 41 | this.data = data; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/com/njfu/ia/sys/domain/ChartData.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.sys.domain; 2 | 3 | import java.util.List; 4 | import java.util.Map; 5 | 6 | /** 7 | * 生成图标所用的数据 8 | */ 9 | public class ChartData { 10 | 11 | /** 12 | * x轴数据 13 | */ 14 | private List dateList; 15 | 16 | /** 17 | * 数据类型名称-数据列表 18 | */ 19 | private Map> dataMap; 20 | 21 | public ChartData(List dateList, Map> dataMap) { 22 | this.dateList = dateList; 23 | this.dataMap = dataMap; 24 | } 25 | 26 | public List getDateList() { 27 | return dateList; 28 | } 29 | 30 | public void setDateList(List dateList) { 31 | this.dateList = dateList; 32 | } 33 | 34 | public Map> getDataMap() { 35 | return dataMap; 36 | } 37 | 38 | public void setDataMap(Map> dataMap) { 39 | this.dataMap = dataMap; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/com/njfu/ia/sys/mapper/AlarmRecordMapper.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.sys.mapper; 2 | 3 | import com.njfu.ia.sys.domain.AlarmRecord; 4 | import org.apache.ibatis.annotations.Mapper; 5 | import org.apache.ibatis.annotations.Param; 6 | 7 | import java.util.List; 8 | 9 | @Mapper 10 | public interface AlarmRecordMapper { 11 | 12 | /** 13 | * 查询报警记录 14 | * 15 | * @param alarmRecord alarmRecord 16 | * @return 17 | */ 18 | List selectAlarmRecord(@Param("alarmRecord") AlarmRecord alarmRecord, 19 | @Param("start") String start, 20 | @Param("end") String end); 21 | 22 | /** 23 | * 修改报警记录处理状态 24 | * 25 | * @return 26 | */ 27 | int updateAlarmRecordHandleFlag(@Param("ids") Integer[] ids, @Param("flag") Integer flag); 28 | 29 | /** 30 | * 获取报警记录数量 31 | * 32 | * @param 33 | * @return 34 | */ 35 | int selectCount(@Param("flag") String flag); 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/main/resources/templates/common/echarts.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /IA-PCS/src/main/java/com/njfu/ia/process/domain/InformRet.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.process.domain; 2 | 3 | import com.fasterxml.jackson.annotation.JsonInclude; 4 | 5 | /** 6 | * 通知报文 7 | */ 8 | @JsonInclude(JsonInclude.Include.NON_NULL) 9 | public class InformRet { 10 | 11 | /** 12 | * 通知消息类型 13 | */ 14 | private int msgType; 15 | 16 | /** 17 | * 终端设备编号 18 | */ 19 | private Integer deviceId; 20 | 21 | /** 22 | * 数据记录 23 | */ 24 | private AlarmRecord record; 25 | 26 | public int getMsgType() { 27 | return msgType; 28 | } 29 | 30 | public void setMsgType(int msgType) { 31 | this.msgType = msgType; 32 | } 33 | 34 | public Integer getDeviceId() { 35 | return deviceId; 36 | } 37 | 38 | public void setDeviceId(Integer deviceId) { 39 | this.deviceId = deviceId; 40 | } 41 | 42 | public AlarmRecord getRecord() { 43 | return record; 44 | } 45 | 46 | public void setRecord(AlarmRecord record) { 47 | this.record = record; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/test/java/com/njfu/ia/sys/mapper/EndDeviceMapperTest.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.sys.mapper; 2 | 3 | import com.njfu.ia.sys.domain.EndDevice; 4 | import org.junit.Test; 5 | import org.junit.runner.RunWith; 6 | import org.slf4j.Logger; 7 | import org.slf4j.LoggerFactory; 8 | import org.springframework.boot.test.context.SpringBootTest; 9 | import org.springframework.test.context.junit4.SpringRunner; 10 | import org.springframework.transaction.annotation.Transactional; 11 | 12 | import javax.annotation.Resource; 13 | import java.util.List; 14 | 15 | @RunWith(SpringRunner.class) 16 | @SpringBootTest 17 | @Transactional 18 | public class EndDeviceMapperTest { 19 | 20 | private static final Logger LOGGER = LoggerFactory.getLogger(EndDeviceMapperTest.class); 21 | 22 | @Resource 23 | private EndDeviceMapper endDeviceMapper; 24 | 25 | @Test 26 | public void selectEndDevices() { 27 | List endDevices = endDeviceMapper.selectEndDevices(new EndDevice()); 28 | LOGGER.info("endDevices: {}", endDevices); 29 | } 30 | } -------------------------------------------------------------------------------- /src/main/java/com/njfu/ia/sys/service/UpstreamDataRecordService.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.sys.service; 2 | 3 | import com.njfu.ia.sys.domain.ChartData; 4 | import com.njfu.ia.sys.domain.UpstreamDataRecord; 5 | 6 | import java.util.List; 7 | 8 | public interface UpstreamDataRecordService { 9 | 10 | /** 11 | * 查询上传数据记录 12 | * 13 | * @param dataRecord 14 | * @param start 15 | * @param end 16 | * @return 17 | */ 18 | List queryDataRecords(UpstreamDataRecord dataRecord, String start, String end); 19 | 20 | 21 | /** 22 | * 根据区块编号查询近期数据上传记录 23 | * 24 | * @param sectionId 25 | * @return 26 | */ 27 | List queryLastDataRecords(Integer sectionId); 28 | 29 | /** 30 | * 构造图表数据 31 | * 32 | * @param dataTypes 33 | * @param sectionId 34 | * @param start 35 | * @param end 36 | * @return 37 | */ 38 | ChartData constructChartData(Integer[] dataTypes, Integer sectionId, String start, String end); 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/com/njfu/ia/sys/mapper/BlockMapper.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.sys.mapper; 2 | 3 | import com.njfu.ia.sys.domain.Block; 4 | import org.apache.ibatis.annotations.Mapper; 5 | import org.apache.ibatis.annotations.Param; 6 | 7 | import java.util.List; 8 | 9 | @Mapper 10 | public interface BlockMapper { 11 | 12 | /** 13 | * 查询地块信息 14 | * 15 | * @param block 16 | * @return 17 | */ 18 | List selectBlocks(Block block); 19 | 20 | /** 21 | * 查询所有地块信息及相应地块下使用状态的区块 22 | * 23 | * @return 24 | */ 25 | List selectBlocksWithSections(); 26 | 27 | /** 28 | * 新增地块信息 29 | * 30 | * @param block 31 | * @return 32 | */ 33 | int insertBlock(Block block); 34 | 35 | /** 36 | * 修改地块信息 37 | * 38 | * @param block 39 | * @return 40 | */ 41 | int updateBlock(Block block); 42 | 43 | /** 44 | * 删除地块信息 45 | * 46 | * @param id 47 | * @return 48 | */ 49 | int deleteBlock(@Param("id") Integer id); 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/com/njfu/ia/sys/mapper/IrrigationPlanMapper.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.sys.mapper; 2 | 3 | import com.njfu.ia.sys.domain.IrrigationPlan; 4 | import org.apache.ibatis.annotations.Mapper; 5 | import org.apache.ibatis.annotations.Param; 6 | 7 | import java.util.List; 8 | 9 | @Mapper 10 | public interface IrrigationPlanMapper { 11 | 12 | /** 13 | * 获取灌溉方案列表 14 | * 15 | * @param irrigationPlan 16 | * @return 17 | */ 18 | List selectIrrigationPlans(IrrigationPlan irrigationPlan); 19 | 20 | /** 21 | * 新增灌溉方案 22 | * 23 | * @param irrigationPlan 24 | * @return 25 | */ 26 | int insertIrrigationPlan(IrrigationPlan irrigationPlan); 27 | 28 | /** 29 | * 更新灌溉方案 30 | * 31 | * @param irrigationPlan 32 | * @return 33 | */ 34 | int updateIrrigationPlan(IrrigationPlan irrigationPlan); 35 | 36 | /** 37 | * 删除灌溉方案 38 | * 39 | * @param id 40 | * @return 41 | */ 42 | int deleteIrrigationPlan(@Param("id") Integer id); 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/com/njfu/ia/sys/domain/InformRet.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.sys.domain; 2 | 3 | import com.fasterxml.jackson.annotation.JsonInclude; 4 | 5 | /** 6 | * 通知报文 7 | */ 8 | @JsonInclude(JsonInclude.Include.NON_NULL) 9 | public class InformRet { 10 | 11 | /** 12 | * 通知消息类型 13 | */ 14 | private int msgType; 15 | 16 | /** 17 | * 终端设备编号 18 | */ 19 | private Integer deviceId; 20 | 21 | /** 22 | * 数据记录 23 | */ 24 | private AlarmRecord record; 25 | 26 | public int getMsgType() { 27 | return msgType; 28 | } 29 | 30 | public void setMsgType(int msgType) { 31 | this.msgType = msgType; 32 | } 33 | 34 | public Integer getDeviceId() { 35 | return deviceId; 36 | } 37 | 38 | public void setDeviceId(Integer deviceId) { 39 | this.deviceId = deviceId; 40 | } 41 | 42 | public AlarmRecord getRecord() { 43 | return record; 44 | } 45 | 46 | public void setRecord(AlarmRecord record) { 47 | this.record = record; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/com/njfu/ia/sys/mapper/MemoMapper.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.sys.mapper; 2 | 3 | import com.njfu.ia.sys.domain.Memo; 4 | import org.apache.ibatis.annotations.Mapper; 5 | import org.apache.ibatis.annotations.Param; 6 | 7 | import java.util.List; 8 | 9 | @Mapper 10 | public interface MemoMapper { 11 | 12 | /** 13 | * 根据类型获取记录标题列表 14 | * 15 | * @param type 16 | * @return 17 | */ 18 | List selectMemoList(@Param("type") Integer type); 19 | 20 | /** 21 | * 根据id获取记录 22 | * 23 | * @param id 24 | * @return 25 | */ 26 | Memo selectMemo(@Param("id") int id); 27 | 28 | /** 29 | * 新增记录 30 | * 31 | * @param memo 32 | * @return 33 | */ 34 | int insertMemo(Memo memo); 35 | 36 | /** 37 | * 修改记录 38 | * 39 | * @param memo 40 | * @return 41 | */ 42 | int updateMemo(Memo memo); 43 | 44 | /** 45 | * 删除记录 46 | * 47 | * @param id 48 | * @return 49 | */ 50 | int deleteMemo(@Param("id") Integer id); 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/com/njfu/ia/sys/service/MachineService.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.sys.service; 2 | 3 | import com.njfu.ia.sys.domain.Block; 4 | import com.njfu.ia.sys.domain.Machine; 5 | 6 | import java.util.List; 7 | 8 | public interface MachineService { 9 | 10 | /** 11 | * 获取机械列表 12 | * 13 | * @param machine machineId machineType useStatus 14 | * @param block blockId 15 | * @return data 16 | */ 17 | List queryMachines(Machine machine, Block block); 18 | 19 | /** 20 | * 新增机械信息 21 | * 22 | * @param machine machineId machineType useStatus machinePs 23 | * @param block blockId 24 | */ 25 | void addMachine(Machine machine, Block block); 26 | 27 | /** 28 | * 修改机械信息 29 | * 30 | * @param machine machineId machineType useStatus machinePs 31 | * @param block blockId 32 | */ 33 | void modifyMachine(Machine machine, Block block); 34 | 35 | /** 36 | * 删除机械信息 37 | * 38 | * @param machine machineId 39 | */ 40 | void removeMachine(Machine machine); 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/com/njfu/ia/sys/service/SensorService.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.sys.service; 2 | 3 | import com.njfu.ia.sys.domain.Field; 4 | import com.njfu.ia.sys.domain.Sensor; 5 | 6 | import java.util.List; 7 | 8 | public interface SensorService { 9 | 10 | /** 11 | * 获取传感器列表 12 | * 13 | * @param sensor sensorId sensorFunc sensorType useStatus sensorPs 14 | * @param field fieldId 15 | * @return data 16 | */ 17 | List querySensors(Sensor sensor, Field field); 18 | 19 | /** 20 | * 新增传感器信息 21 | * 22 | * @param sensor sensorId sensorFunc sensorType useStatus sensorPs 23 | * @param field fieldId 24 | */ 25 | void addSensor(Sensor sensor, Field field); 26 | 27 | /** 28 | * 修改传感器信息 29 | * 30 | * @param sensor sensorId sensorFunc sensorType useStatus sensorPs 31 | * @param field fieldId 32 | */ 33 | void modifySensor(Sensor sensor, Field field); 34 | 35 | /** 36 | * 删除传感器信息 37 | * 38 | * @param sensor sensorId 39 | */ 40 | void removeSensor(Sensor sensor); 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/com/njfu/ia/sys/service/MemoService.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.sys.service; 2 | 3 | import com.njfu.ia.sys.domain.Memo; 4 | import com.njfu.ia.sys.exception.BusinessException; 5 | 6 | import java.util.List; 7 | 8 | public interface MemoService { 9 | 10 | /** 11 | * 根据记录类型获取记录列表 12 | * 13 | * @param type 14 | * @return 15 | */ 16 | List queryMemoList(Integer type); 17 | 18 | /** 19 | * 根据记录编号查找记录 20 | * 21 | * @param id 22 | * @return 23 | */ 24 | Memo queryMemo(int id); 25 | 26 | /** 27 | * 新增记录 28 | * 29 | * @param memo 30 | * @throws BusinessException 31 | */ 32 | void addMemo(Memo memo) throws BusinessException; 33 | 34 | /** 35 | * 修改记录 36 | * 37 | * @param memo 38 | * @throws BusinessException 39 | */ 40 | void modifyMemo(Memo memo) throws BusinessException; 41 | 42 | /** 43 | * 删除记录 44 | * 45 | * @param id 46 | * @throws BusinessException 47 | */ 48 | void removeMemo(int id) throws BusinessException; 49 | } 50 | -------------------------------------------------------------------------------- /IA-PCS/src/main/resources/mapper/UploadDataRecordMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | INSERT INTO upstream_data_record(id, data_type, value, receive_time) 10 | VALUES 11 | 12 | (#{record.endDeviceId}, #{record.dataType}, #{record.value}, #{record.receiveTime}) 13 | 14 | 15 | 16 | 25 | 26 | -------------------------------------------------------------------------------- /src/main/resources/mapper/EndDeviceMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 29 | 30 | -------------------------------------------------------------------------------- /IA-LSN/src/main/java/com/njfu/ia/listener/Listener.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.listener; 2 | 3 | import com.njfu.ia.listener.utils.Constants; 4 | import com.njfu.ia.listener.service.OnDataThread; 5 | import org.slf4j.Logger; 6 | import org.slf4j.LoggerFactory; 7 | 8 | import java.net.ServerSocket; 9 | import java.net.Socket; 10 | 11 | /** 12 | * 侦听socket连接侦听器 13 | */ 14 | public class Listener { 15 | 16 | private static final Logger LOGGER = LoggerFactory.getLogger(Listener.class); 17 | 18 | public static void main(String[] args) { 19 | // 在指定端口建立socket服务 20 | try (ServerSocket serverSocket = new ServerSocket(Constants.LISTEN_PORT)) { 21 | LOGGER.info("Server socket service established, listen port {}", Constants.LISTEN_PORT); 22 | while (true) { 23 | // 阻塞状态,等待socket连接 24 | Socket socket = serverSocket.accept(); 25 | // 获取socket连接,新起服务线程 26 | new OnDataThread(socket).start(); 27 | } 28 | } catch (Exception e) { 29 | LOGGER.info("Server Listener Exception: {}", e.getMessage()); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /IA-PCS/src/main/java/com/njfu/ia/process/jms/DestinationConfig.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.process.jms; 2 | 3 | import com.njfu.ia.process.utils.Constants; 4 | import org.apache.activemq.command.ActiveMQQueue; 5 | import org.apache.activemq.command.ActiveMQTopic; 6 | import org.springframework.context.annotation.Bean; 7 | import org.springframework.context.annotation.Configuration; 8 | 9 | import javax.jms.Queue; 10 | import javax.jms.Topic; 11 | 12 | @Configuration 13 | public class DestinationConfig { 14 | 15 | @Bean 16 | public Queue upstreamHeart() { 17 | return new ActiveMQQueue(Constants.QUEUE_UPSTREAM_HEART); 18 | } 19 | 20 | @Bean 21 | public Queue upstreamData() { 22 | return new ActiveMQQueue(Constants.QUEUE_UPSTREAM_DATA); 23 | } 24 | 25 | @Bean 26 | public Topic downstreamHeart() { 27 | return new ActiveMQTopic(Constants.TOPIC_DOWNSTREAM_HEART); 28 | } 29 | 30 | @Bean 31 | public Queue informHeart() { 32 | return new ActiveMQQueue(Constants.QUEUE_INFORM_HEART); 33 | } 34 | 35 | @Bean 36 | public Queue informAlarm() { 37 | return new ActiveMQQueue(Constants.QUEUE_INFORM_ALARM); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /IA-PCS/src/main/java/com/njfu/ia/process/domain/Section.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.process.domain; 2 | 3 | /** 4 | * 区块 5 | */ 6 | public class Section { 7 | 8 | /** 9 | * 区块编号 10 | */ 11 | private Integer id; 12 | 13 | /** 14 | * 区块名称 15 | */ 16 | private String sectionName; 17 | 18 | /** 19 | * 所属地块编号 20 | */ 21 | private Integer blockId; 22 | 23 | public Section() { 24 | } 25 | 26 | public Integer getId() { 27 | return id; 28 | } 29 | 30 | public void setId(Integer id) { 31 | this.id = id; 32 | } 33 | 34 | public String getSectionName() { 35 | return sectionName; 36 | } 37 | 38 | public void setSectionName(String sectionName) { 39 | this.sectionName = sectionName; 40 | } 41 | 42 | public Integer getBlockId() { 43 | return blockId; 44 | } 45 | 46 | public void setBlockId(Integer blockId) { 47 | this.blockId = blockId; 48 | } 49 | 50 | @Override 51 | public String toString() { 52 | return "Section{" + 53 | "id=" + id + 54 | ", sectionName='" + sectionName + '\'' + 55 | ", blockId=" + blockId + 56 | '}'; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/com/njfu/ia/sys/domain/Section.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.sys.domain; 2 | 3 | /** 4 | * 区块 5 | */ 6 | public class Section { 7 | 8 | /** 9 | * 区块编号 10 | */ 11 | private Integer id; 12 | 13 | /** 14 | * 区块名称 15 | */ 16 | private String sectionName; 17 | 18 | /** 19 | * 所属地块编号 20 | */ 21 | private Integer blockId; 22 | 23 | /** 24 | * 所属地块名称 25 | */ 26 | private String blockName; 27 | 28 | public Section() { 29 | } 30 | 31 | public Integer getId() { 32 | return id; 33 | } 34 | 35 | public void setId(Integer id) { 36 | this.id = id; 37 | } 38 | 39 | public String getSectionName() { 40 | return sectionName; 41 | } 42 | 43 | public void setSectionName(String sectionName) { 44 | this.sectionName = sectionName; 45 | } 46 | 47 | public Integer getBlockId() { 48 | return blockId; 49 | } 50 | 51 | public void setBlockId(Integer blockId) { 52 | this.blockId = blockId; 53 | } 54 | 55 | public String getBlockName() { 56 | return blockName; 57 | } 58 | 59 | public void setBlockName(String blockName) { 60 | this.blockName = blockName; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/main/resources/mapper/CropMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 17 | 18 | 25 | 26 | 27 | INSERT INTO crop (crop_name) 28 | VALUES (#{cropName}) 29 | 30 | 31 | 32 | UPDATE crop 33 | SET crop_name = #{cropName} 34 | WHERE id = #{id} 35 | 36 | 37 | 38 | DELETE FROM crop 39 | WHERE id = #{id} 40 | 41 | -------------------------------------------------------------------------------- /src/main/resources/mapper/FieldStatusMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | INSERT INTO field_status (field_id) 10 | VALUES (#{fieldId}) 11 | 12 | 13 | 32 | 33 | 34 | DELETE 35 | FROM field_status 36 | WHERE field_id = #{fieldId} 37 | 38 | 39 | 44 | 45 | -------------------------------------------------------------------------------- /src/test/java/com/njfu/ia/test/SimpleTest.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.test; 2 | 3 | import org.apache.shiro.crypto.hash.SimpleHash; 4 | import org.apache.shiro.util.ByteSource; 5 | import org.junit.Test; 6 | import org.springframework.util.DigestUtils; 7 | 8 | import java.util.ArrayList; 9 | import java.util.Iterator; 10 | import java.util.List; 11 | 12 | public class SimpleTest { 13 | 14 | @Test 15 | public void getShiroMd5Password() { 16 | String source = "123456"; 17 | String timeMills = "1513685984517"; 18 | SimpleHash md5 = new SimpleHash("md5", source, 19 | ByteSource.Util.bytes(timeMills)); 20 | System.out.println(md5); 21 | } 22 | 23 | @Test 24 | public void test1() { 25 | String md5 = DigestUtils.md5DigestAsHex(String.valueOf(System.currentTimeMillis()).getBytes()); 26 | System.out.println(md5); 27 | } 28 | 29 | @Test 30 | public void test2() { 31 | List list = new ArrayList<>(); 32 | list.add(1); 33 | list.add(2); 34 | 35 | Iterator iterator = list.iterator(); 36 | while (iterator.hasNext()) { 37 | Integer next = iterator.next(); 38 | iterator.remove(); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/resources/templates/common/standard.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /IA-PCS/src/main/java/com/njfu/ia/process/mapper/EndDeviceMapper.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.process.mapper; 2 | 3 | import com.njfu.ia.process.domain.EndDevice; 4 | import org.apache.ibatis.annotations.Mapper; 5 | import org.apache.ibatis.annotations.Param; 6 | 7 | import java.util.List; 8 | 9 | @Mapper 10 | public interface EndDeviceMapper { 11 | 12 | /** 13 | * 通过MAC地址查询对应终端的网络编号 14 | * 15 | * @param macAddress macAddress 16 | * @return EndDevice 17 | */ 18 | EndDevice selectDeviceByMac(String macAddress); 19 | 20 | /** 21 | * 更新终端信息 22 | * 23 | * @param endDevice endDevice 24 | * @return count 25 | */ 26 | int updateDevice(EndDevice endDevice); 27 | 28 | /** 29 | * 查询设备编号 30 | * 31 | * @param deviceIds deviceIds 32 | * @param useStatus useStatus 33 | * @return device id list 34 | */ 35 | List selectDevice(@Param("deviceIds") List deviceIds, @Param("useStatus") Integer useStatus); 36 | 37 | /** 38 | * 批量更新终端使用状态 39 | * 40 | * @param deviceIds deviceIds 41 | * @param useStatus useStatus 42 | * @return count 43 | */ 44 | int batchUpdateDeviceUseStatus(@Param("deviceIds") List deviceIds, @Param("useStatus") Integer useStatus); 45 | } 46 | -------------------------------------------------------------------------------- /IA-LSN/src/main/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n 7 | 8 | 9 | 10 | 11 | 12 | INFO 13 | ACCEPT 14 | DENY 15 | 16 | 17 | log/%d{yyyy-MM-dd}/ia-listener.log 18 | 19 | 20 | %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /src/main/java/com/njfu/ia/sys/domain/Permission.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.sys.domain; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnore; 4 | 5 | /** 6 | * 权限 7 | */ 8 | public class Permission { 9 | 10 | /** 11 | * 权限编号 12 | */ 13 | private Integer id; 14 | 15 | /** 16 | * url地址 17 | */ 18 | @JsonIgnore 19 | private String url; 20 | 21 | /** 22 | * url描述 23 | */ 24 | private String urlName; 25 | 26 | /** 27 | * 权限标识符 28 | */ 29 | @JsonIgnore 30 | private String perm; 31 | 32 | public Integer getId() { 33 | return id; 34 | } 35 | 36 | public void setId(Integer id) { 37 | this.id = id; 38 | } 39 | 40 | public String getUrl() { 41 | return url; 42 | } 43 | 44 | public void setUrl(String url) { 45 | this.url = url; 46 | } 47 | 48 | public String getUrlName() { 49 | return urlName; 50 | } 51 | 52 | public void setUrlName(String urlName) { 53 | this.urlName = urlName; 54 | } 55 | 56 | public String getPerm() { 57 | return perm; 58 | } 59 | 60 | public void setPerm(String perm) { 61 | this.perm = perm; 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/com/njfu/ia/sys/mapper/MachineMapper.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.sys.mapper; 2 | 3 | import com.njfu.ia.sys.domain.Machine; 4 | import org.apache.ibatis.annotations.Mapper; 5 | import org.apache.ibatis.annotations.Param; 6 | 7 | import java.util.List; 8 | 9 | @Mapper 10 | public interface MachineMapper { 11 | 12 | /** 13 | * 获取机械列表 14 | * 15 | * @param machine machineId machineType blockId useStatus 16 | * @return data 17 | */ 18 | List selectMachines(Machine machine); 19 | 20 | /** 21 | * 新增机械信息 22 | * 23 | * @param machine machineId machineType blockId useStatus 24 | * @return row count 25 | */ 26 | int insertMachine(Machine machine); 27 | 28 | /** 29 | * 修改机械信息 30 | * 31 | * @param machine machineId machineType blockId useStatus 32 | * @return row count 33 | */ 34 | int updateMachine(Machine machine); 35 | 36 | /** 37 | * 删除机械信息 38 | * 39 | * @param machine machineId 40 | * @return row count 41 | */ 42 | int deleteMachine(Machine machine); 43 | 44 | /** 45 | * 将属于某地块下的机械所属大棚置空 46 | * 47 | * @param blockId 48 | * @return 49 | */ 50 | int updateMachineByBlock(@Param("blockId") String blockId); 51 | } 52 | -------------------------------------------------------------------------------- /IA-LSN/src/test/java/com/njfu/ia/listener/SocketTest.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.listener; 2 | 3 | 4 | import com.njfu.ia.listener.utils.Constants; 5 | import org.junit.Before; 6 | import org.junit.Test; 7 | 8 | import java.io.IOException; 9 | import java.io.OutputStream; 10 | import java.net.Socket; 11 | 12 | public class SocketTest { 13 | 14 | private Socket socket; 15 | 16 | private OutputStream os; 17 | 18 | @Before 19 | public void before() throws IOException { 20 | socket = new Socket("127.0.0.1", 9040); 21 | os = socket.getOutputStream(); 22 | } 23 | 24 | @Test 25 | public void test1() throws IOException, InterruptedException { 26 | byte[] message = constructMessage("tp:0|mac:00-12-4B-00-03-98-A1-AB"); 27 | while (true) { 28 | os.write(message); 29 | os.flush(); 30 | Thread.sleep(1000); 31 | } 32 | } 33 | 34 | 35 | private byte[] constructMessage(String message) { 36 | int length = message.length(); 37 | byte[] data = new byte[length + 3]; 38 | 39 | int x = 0; 40 | data[x++] = Constants.START_FLAG; 41 | for (byte b : message.getBytes()) { 42 | data[x++] = b; 43 | } 44 | 45 | data[x++] = (byte) length; 46 | data[x] = Constants.END_FLAG; 47 | 48 | return data; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/com/njfu/ia/sys/domain/Block.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.sys.domain; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * 地块 7 | */ 8 | public class Block { 9 | 10 | /** 11 | * 地块编号 12 | */ 13 | private Integer id; 14 | 15 | /** 16 | * 地块名称 17 | */ 18 | private String blockName; 19 | 20 | /** 21 | * 地块位置 22 | */ 23 | private String blockLocation; 24 | 25 | /** 26 | * 包含区块 27 | */ 28 | private List
sections; 29 | 30 | public Block() { 31 | } 32 | 33 | public Integer getId() { 34 | return id; 35 | } 36 | 37 | public void setId(Integer id) { 38 | this.id = id; 39 | } 40 | 41 | public String getBlockName() { 42 | return blockName; 43 | } 44 | 45 | public void setBlockName(String blockName) { 46 | this.blockName = blockName; 47 | } 48 | 49 | public String getBlockLocation() { 50 | return blockLocation; 51 | } 52 | 53 | public void setBlockLocation(String blockLocation) { 54 | this.blockLocation = blockLocation; 55 | } 56 | 57 | public List
getSections() { 58 | return sections; 59 | } 60 | 61 | public void setSections(List
sections) { 62 | this.sections = sections; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/com/njfu/ia/sys/utils/page/PageAspect.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.sys.utils.page; 2 | 3 | import com.github.pagehelper.PageHelper; 4 | import org.aspectj.lang.ProceedingJoinPoint; 5 | import org.aspectj.lang.annotation.Around; 6 | import org.aspectj.lang.annotation.Aspect; 7 | import org.aspectj.lang.annotation.Pointcut; 8 | import org.springframework.stereotype.Component; 9 | 10 | @Aspect 11 | @Component 12 | public class PageAspect { 13 | 14 | /** 15 | * 设置切入点为标注有 @PageOffset 注解的路由方法 16 | */ 17 | @Pointcut("@annotation(com.njfu.ia.sys.utils.page.PageOffset)") 18 | public void pageOffset() { 19 | } 20 | 21 | @Around("pageOffset()") 22 | public Object aroundPaginationRequest(ProceedingJoinPoint joinPoint) { 23 | Object result = null; 24 | Object[] args = joinPoint.getArgs(); 25 | Integer offset = (Integer) args[0]; 26 | Integer limit = (Integer) args[1]; 27 | 28 | if (null != offset && null != limit) { 29 | PageHelper.offsetPage(offset, limit); 30 | } else { 31 | PageHelper.offsetPage(0, Short.MAX_VALUE); 32 | } 33 | 34 | try { 35 | result = joinPoint.proceed(args); 36 | } catch (Throwable throwable) { 37 | result = null; 38 | } 39 | return result; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /IA-PCS/src/main/java/com/njfu/ia/process/domain/DownstreamRet.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.process.domain; 2 | 3 | import com.fasterxml.jackson.annotation.JsonInclude; 4 | 5 | import java.util.Map; 6 | 7 | /** 8 | * 下行报文 9 | */ 10 | @JsonInclude(JsonInclude.Include.NON_NULL) 11 | public class DownstreamRet { 12 | 13 | /** 14 | * 消息类型 15 | */ 16 | private Integer msgType; 17 | 18 | /** 19 | * 终端设备编号 20 | */ 21 | private Integer deviceId; 22 | 23 | /** 24 | * 终端设备mac地址 25 | */ 26 | private String mac; 27 | 28 | /** 29 | * 命令 30 | */ 31 | private Map command; 32 | 33 | public Integer getMsgType() { 34 | return msgType; 35 | } 36 | 37 | public void setMsgType(Integer msgType) { 38 | this.msgType = msgType; 39 | } 40 | 41 | public Integer getDeviceId() { 42 | return deviceId; 43 | } 44 | 45 | public void setDeviceId(Integer deviceId) { 46 | this.deviceId = deviceId; 47 | } 48 | 49 | public String getMac() { 50 | return mac; 51 | } 52 | 53 | public void setMac(String mac) { 54 | this.mac = mac; 55 | } 56 | 57 | public Map getCommand() { 58 | return command; 59 | } 60 | 61 | public void setCommand(Map command) { 62 | this.command = command; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/main/resources/mapper/IrrigationPlanMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 20 | 21 | 22 | INSERT INTO irrigation_plan (id, plan_volume, duration) 23 | VALUES (NULL, #{planVolume}, #{duration}) 24 | 25 | 26 | 27 | UPDATE irrigation_plan 28 | 29 | 30 | plan_volume = #{planVolume}, 31 | 32 | 33 | duration = #{duration}, 34 | 35 | 36 | WHERE id = #{id} 37 | 38 | 39 | 40 | DELETE FROM irrigation_plan 41 | WHERE id = #{id} 42 | 43 | -------------------------------------------------------------------------------- /IA-PCS/src/main/java/com/njfu/ia/process/jms/consumer/UpstreamOnAndHeartMessageConsumer.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.process.jms.consumer; 2 | 3 | import com.njfu.ia.process.service.UpstreamService; 4 | import com.njfu.ia.process.utils.Constants; 5 | import org.slf4j.Logger; 6 | import org.slf4j.LoggerFactory; 7 | import org.springframework.jms.annotation.JmsListener; 8 | import org.springframework.stereotype.Component; 9 | 10 | import javax.annotation.Resource; 11 | import javax.jms.JMSException; 12 | import javax.jms.Message; 13 | import javax.jms.TextMessage; 14 | 15 | @Component 16 | public class UpstreamOnAndHeartMessageConsumer { 17 | 18 | private static final Logger LOGGER = LoggerFactory.getLogger(UpstreamOnAndHeartMessageConsumer.class); 19 | 20 | @Resource 21 | private UpstreamService upstreamService; 22 | 23 | @JmsListener(destination = Constants.QUEUE_UPSTREAM_HEART, concurrency = Constants.DEFAULT_CONCURRENCY_RANGE) 24 | public void onMessage(Message message) { 25 | try { 26 | if (message instanceof TextMessage) { 27 | String messageText = ((TextMessage) message).getText(); 28 | // 处理上行数据 29 | upstreamService.consumeUpstreamMessage(messageText); 30 | LOGGER.info("UpstreamOnAndHeartMessageConsumer consume message: {}", messageText); 31 | } 32 | } catch (JMSException e) { 33 | LOGGER.error("UpstreamOnAndHeartMessageConsumer Exception", e); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /IA-LSN/src/main/java/com/njfu/ia/listener/utils/JsonUtils.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.listener.utils; 2 | 3 | import com.fasterxml.jackson.core.JsonProcessingException; 4 | import com.fasterxml.jackson.databind.ObjectMapper; 5 | import org.slf4j.Logger; 6 | import org.slf4j.LoggerFactory; 7 | 8 | import java.io.IOException; 9 | 10 | /** 11 | * Json工具类 12 | * base on jackson 13 | */ 14 | public class JsonUtils { 15 | 16 | private static final ObjectMapper MAPPER = new ObjectMapper(); 17 | 18 | private static final Logger LOGGER = LoggerFactory.getLogger(JsonUtils.class); 19 | 20 | /** 21 | * Object转json字符串 22 | * 23 | * @param object object 24 | * @return String 25 | */ 26 | public static String toJsonString(Object object) { 27 | String json = null; 28 | try { 29 | json = MAPPER.writeValueAsString(object); 30 | } catch (JsonProcessingException e) { 31 | LOGGER.error("JsonUtils.toJsonString Exception", e); 32 | } 33 | return json; 34 | } 35 | 36 | /** 37 | * json格式字符串转Bean 38 | * 39 | * @param json json 40 | * @param clazz Class.Type 41 | * @param T 42 | * @return T 43 | */ 44 | public static T toBean(String json, Class clazz) { 45 | T t = null; 46 | try { 47 | t = MAPPER.readValue(json, clazz); 48 | } catch (IOException e) { 49 | LOGGER.error("JsonUtils.toBean Exception", e); 50 | } 51 | return t; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /IA-PCS/src/main/java/com/njfu/ia/process/utils/JsonUtils.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.process.utils; 2 | 3 | import com.fasterxml.jackson.core.JsonProcessingException; 4 | import com.fasterxml.jackson.databind.ObjectMapper; 5 | import org.slf4j.Logger; 6 | import org.slf4j.LoggerFactory; 7 | 8 | import java.io.IOException; 9 | 10 | /** 11 | * Json工具类 12 | * base on jackson 13 | */ 14 | public class JsonUtils { 15 | 16 | private static final ObjectMapper MAPPER = new ObjectMapper(); 17 | 18 | private static final Logger LOGGER = LoggerFactory.getLogger(JsonUtils.class); 19 | 20 | /** 21 | * Object转json字符串 22 | * 23 | * @param object object 24 | * @return String 25 | */ 26 | public static String toJsonString(Object object) { 27 | String json = null; 28 | try { 29 | json = MAPPER.writeValueAsString(object); 30 | } catch (JsonProcessingException e) { 31 | LOGGER.error("JsonUtils.toJsonString Exception", e); 32 | } 33 | return json; 34 | } 35 | 36 | /** 37 | * json格式字符串转Bean 38 | * 39 | * @param json json 40 | * @param clazz Class.Type 41 | * @param T 42 | * @return T 43 | */ 44 | public static T toBean(String json, Class clazz) { 45 | T t = null; 46 | try { 47 | t = MAPPER.readValue(json, clazz); 48 | } catch (IOException e) { 49 | LOGGER.error("JsonUtils.toBean Exception", e); 50 | } 51 | return t; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /IA-PCS/src/main/java/com/njfu/ia/process/jms/consumer/handler/HeartUpstreamHandler.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.process.jms.consumer.handler; 2 | 3 | import com.njfu.ia.process.domain.EndDevice; 4 | import com.njfu.ia.process.mapper.EndDeviceMapper; 5 | import com.njfu.ia.process.utils.Constants; 6 | import org.slf4j.Logger; 7 | import org.slf4j.LoggerFactory; 8 | 9 | import javax.annotation.Resource; 10 | import java.util.Date; 11 | import java.util.Map; 12 | 13 | /** 14 | * 心跳上行数据处理器 15 | */ 16 | public class HeartUpstreamHandler extends UpstreamHandler { 17 | 18 | private static final Logger LOGGER = LoggerFactory.getLogger(HeartUpstreamHandler.class); 19 | 20 | @Resource 21 | private EndDeviceMapper endDeviceMapper; 22 | 23 | public HeartUpstreamHandler(Date receiveTime, Map retMap) { 24 | super(receiveTime, retMap); 25 | } 26 | 27 | /** 28 | * 处理心跳反馈 29 | * 更新终端使用中状态 tp:3|id:1 30 | */ 31 | @Override 32 | public void handleUpstream() { 33 | Map retMap = super.getRetMap(); 34 | Integer deviceId = (Integer) retMap.get(Constants.RET_ID); 35 | if (null != deviceId) { 36 | EndDevice device = new EndDevice(); 37 | device.setId(deviceId); 38 | device.setUseStatus(Constants.INUSE); 39 | int count = endDeviceMapper.updateDevice(device); 40 | if (count <= 0) { 41 | LOGGER.error("heart back update end device {} failed", deviceId); 42 | } 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/com/njfu/ia/sys/utils/JsonUtils.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.sys.utils; 2 | 3 | import com.fasterxml.jackson.core.JsonProcessingException; 4 | import com.fasterxml.jackson.databind.ObjectMapper; 5 | import org.slf4j.Logger; 6 | import org.slf4j.LoggerFactory; 7 | 8 | import java.io.IOException; 9 | 10 | /** 11 | * Json工具类 12 | * base on jackson 13 | */ 14 | public class JsonUtils { 15 | 16 | private static final ObjectMapper MAPPER = new ObjectMapper(); 17 | 18 | private static final Logger LOGGER = LoggerFactory.getLogger(JsonUtils.class); 19 | 20 | /** 21 | * Object转json字符串 22 | * 23 | * @param object object 24 | * @return String 25 | */ 26 | public static String toJsonString(Object object) { 27 | String json = null; 28 | try { 29 | json = MAPPER.writeValueAsString(object); 30 | } catch (JsonProcessingException e) { 31 | LOGGER.error("JsonUtils.toJsonString Exception", e); 32 | } 33 | return json; 34 | } 35 | 36 | /** 37 | * json格式字符串转Bean 38 | * 39 | * @param json json 40 | * @param clazz Class.Type 41 | * @param T 42 | * @return T 43 | */ 44 | public static T toBean(String json, Class clazz) { 45 | T t = null; 46 | try { 47 | t = MAPPER.readValue(json, clazz); 48 | } catch (IOException e) { 49 | LOGGER.error("JsonUtils.toBean Exception", e); 50 | } 51 | return t; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/com/njfu/ia/sys/websocket/TipWebSocketConfig.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.sys.websocket; 2 | 3 | import com.njfu.ia.sys.utils.Constants; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.web.socket.config.annotation.EnableWebSocket; 6 | import org.springframework.web.socket.config.annotation.WebSocketConfigurer; 7 | import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry; 8 | 9 | import javax.annotation.Resource; 10 | 11 | /** 12 | * 系统提示WebSocket配置 13 | */ 14 | @Configuration 15 | @EnableWebSocket 16 | public class TipWebSocketConfig implements WebSocketConfigurer { 17 | 18 | @Resource 19 | private TipHandler tipHandler; 20 | 21 | @Resource 22 | private TipHandShakeInterceptor tipHandShakeInterceptor; 23 | 24 | /** 25 | * 注册WebSocket处理器 26 | * 配置处理器、拦截器、允许域、SockJs支持 27 | * 28 | * @param registry registry 29 | */ 30 | @Override 31 | public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) { 32 | String origin = Constants.WS_ORIGIN; 33 | 34 | registry.addHandler(tipHandler, "/tip/handler") 35 | .addInterceptors(tipHandShakeInterceptor) 36 | .setAllowedOrigins(origin); 37 | 38 | // 当浏览器不支持WebSocket,使用SockJs支持 39 | registry.addHandler(tipHandler, "/sockjs/tip/handler") 40 | .addInterceptors(tipHandShakeInterceptor) 41 | .setAllowedOrigins(origin) 42 | .withSockJS(); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/com/njfu/ia/sys/mapper/SensorMapper.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.sys.mapper; 2 | 3 | import com.njfu.ia.sys.domain.Sensor; 4 | import org.apache.ibatis.annotations.Mapper; 5 | import org.apache.ibatis.annotations.Param; 6 | 7 | import java.util.List; 8 | 9 | @Mapper 10 | public interface SensorMapper { 11 | 12 | /** 13 | * 获取传感器列表 14 | * 15 | * @param sensor sensorId sensorFunc sensorType fieldId useStatus sensorPs 16 | * @return data 17 | */ 18 | List selectSensors(Sensor sensor); 19 | 20 | /** 21 | * 新增传感器信息 22 | * 23 | * @param sensor sensorId sensorFunc sensorType fieldId useStatus sensorPs 24 | * @return row count 25 | */ 26 | int insertSensor(Sensor sensor); 27 | 28 | /** 29 | * 修改传感器信息 30 | * 31 | * @param sensor sensorId sensorFunc sensorType fieldId useStatus sensorPs 32 | * @return row count 33 | */ 34 | int updateSensor(Sensor sensor); 35 | 36 | /** 37 | * 删除传感器信息 38 | * 39 | * @param sensor sensorId 40 | * @return row count 41 | */ 42 | int deleteSensor(Sensor sensor); 43 | 44 | /** 45 | * 将对应传感器的fieldId置空 46 | * 47 | * @param fieldId fieldId 48 | * @return count 49 | */ 50 | int updateSensorField(@Param("fieldId") String fieldId); 51 | 52 | /** 53 | * 查询指定fieldId对应的sensorId 54 | * 55 | * @param fieldId fieldId 56 | * @return data 57 | */ 58 | List selectSensorsByField(@Param("fieldId") String fieldId); 59 | } 60 | -------------------------------------------------------------------------------- /src/main/resources/mapper/SectionMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 19 | 20 | 25 | 26 | 27 | INSERT INTO section (section_name, block_id) 28 | VALUES (#{sectionName}, #{blockId}) 29 | 30 | 31 | 32 | UPDATE section 33 | 34 | 35 | section_name = #{sectionName}, 36 | 37 | 38 | block_id = #{blockId} 39 | 40 | 41 | WHERE id = #{id} 42 | 43 | 44 | 45 | DELETE FROM section 46 | WHERE id = #{id} 47 | 48 | 49 | -------------------------------------------------------------------------------- /src/main/resources/templates/login.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 登录-欢迎使用智慧农业管理系统 10 | 11 | 12 | 13 | 14 | 15 |
16 | 32 | 33 |
34 | 35 | 36 | -------------------------------------------------------------------------------- /src/main/resources/mapper/MemoMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 15 | 16 | 26 | 27 | 28 | INSERT INTO memo (title, type, content, update_user) 29 | VALUES (#{title}, #{type}, #{content}, #{updateUser}) 30 | 31 | 32 | 33 | UPDATE memo 34 | 35 | 36 | title = #{title}, 37 | 38 | 39 | content = #{content}, 40 | 41 | 42 | update_user = #{updateUser} 43 | 44 | 45 | WHERE id = #{id} 46 | 47 | 48 | 49 | DELETE FROM memo 50 | WHERE id = #{id} 51 | 52 | -------------------------------------------------------------------------------- /src/main/resources/templates/sys/help/document.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | <#include "/common/standard.html"/> 6 | 帮助文档 7 | 8 | 9 |
10 | 11 | <#include "/common/topNav.html"/> 12 | 13 | 14 | <#include "/sys/sysSideNav.html"/> 15 | 16 | 17 |
18 |
19 | 22 | 23 |
24 | 28 |
29 | 30 |
31 |
32 |
33 |

帮助文档

34 |
35 |
36 |
    37 |
  • root账号可添加账号,且默认密码为@ia-user
  • 38 |
  • root账号不可删除,且不可修改权限
  • 39 |
40 |
41 |
42 |
43 |
44 |
45 | 46 |
47 | 48 | 49 | -------------------------------------------------------------------------------- /src/main/java/com/njfu/ia/sys/mapper/UpstreamDataRecordMapper.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.sys.mapper; 2 | 3 | import com.njfu.ia.sys.domain.UpstreamDataRecord; 4 | import org.apache.ibatis.annotations.Mapper; 5 | import org.apache.ibatis.annotations.Param; 6 | 7 | import java.util.Date; 8 | import java.util.List; 9 | 10 | @Mapper 11 | public interface UpstreamDataRecordMapper { 12 | 13 | /** 14 | * 查询上传数据记录 15 | * 16 | * @param record 17 | * @param start 18 | * @param end 19 | * @return 20 | */ 21 | List selectDataRecords(@Param("record") UpstreamDataRecord record, 22 | @Param("start") String start, @Param("end") String end); 23 | 24 | /** 25 | * 根据区块编号查询近期有数据上传记录的数据类型及时间 26 | * 27 | * @param sectionId 28 | * @param minutes 29 | * @return 30 | */ 31 | List selectLastReceiveTime(@Param("sectionId") Integer sectionId, 32 | @Param("minutes") long minutes); 33 | 34 | /** 35 | * 查询近期数据上传记录 36 | * 37 | * @param sectionId 38 | * @param dataType 39 | * @param receiveTime 40 | * @param useStatus 41 | * @return 42 | */ 43 | List selectLastDataRecords(@Param("sectionId") Integer sectionId, 44 | @Param("dataType") Integer dataType, 45 | @Param("receiveTime") Date receiveTime, 46 | @Param("useStatus") Integer useStatus); 47 | } 48 | -------------------------------------------------------------------------------- /IA-LSN/src/main/java/com/njfu/ia/listener/jms/DownstreamMessageListener.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.listener.jms; 2 | 3 | import com.njfu.ia.listener.connection.Connections; 4 | import com.njfu.ia.listener.domain.DownstreamRet; 5 | import com.njfu.ia.listener.utils.Constants; 6 | import com.njfu.ia.listener.utils.JsonUtils; 7 | import org.slf4j.Logger; 8 | import org.slf4j.LoggerFactory; 9 | 10 | import javax.jms.Message; 11 | import javax.jms.MessageListener; 12 | import javax.jms.TextMessage; 13 | 14 | /** 15 | * 下行数据监听器,用于将下行数据按通信协议打包 16 | */ 17 | public class DownstreamMessageListener implements MessageListener { 18 | 19 | private static final Logger LOGGER = LoggerFactory.getLogger(DownstreamMessageListener.class); 20 | 21 | @Override 22 | public void onMessage(Message message) { 23 | if (message instanceof TextMessage) { 24 | try { 25 | String text = ((TextMessage) message).getText(); 26 | LOGGER.info("socket service consume message: {}", text); 27 | DownstreamRet downstreamRet = JsonUtils.toBean(text, DownstreamRet.class); 28 | String data = downstreamRet.getData(); 29 | StringBuilder sb = new StringBuilder(); 30 | sb.append((char) Constants.START_FLAG) 31 | .append(data) 32 | .append((byte) data.length()) 33 | .append((char) Constants.END_FLAG); 34 | // 广播命令消息 35 | Connections.broadcast(sb.toString().getBytes()); 36 | } catch (Exception e) { 37 | LOGGER.error("socket service downstream Exception", e); 38 | } 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/com/njfu/ia/sys/mail/MailSender.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.sys.mail; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | import org.springframework.beans.factory.annotation.Value; 6 | import org.springframework.mail.MailException; 7 | import org.springframework.mail.SimpleMailMessage; 8 | import org.springframework.mail.javamail.JavaMailSender; 9 | import org.springframework.stereotype.Service; 10 | 11 | import javax.annotation.Resource; 12 | import java.util.List; 13 | 14 | @Service 15 | public class MailSender { 16 | 17 | @Resource 18 | private JavaMailSender mailSender; 19 | 20 | @Value("${spring.mail.username}") 21 | private String from; 22 | 23 | private static final Logger LOGGER = LoggerFactory.getLogger(MailSender.class); 24 | 25 | /** 26 | * batch send simple mail 27 | * 28 | * @param subject title 29 | * @param text text 30 | * @param toList toList 31 | */ 32 | public void sendSimpleMail(String subject, String text, List toList) { 33 | SimpleMailMessage mailMessage = new SimpleMailMessage(); 34 | mailMessage.setFrom(from); 35 | mailMessage.setSubject(subject); 36 | mailMessage.setText(text); 37 | 38 | int succeedSendCount = 0; 39 | for (String to : toList) { 40 | try { 41 | mailMessage.setTo(to); 42 | mailSender.send(mailMessage); 43 | succeedSendCount++; 44 | } catch (MailException e) { 45 | LOGGER.error("send to {} exception, {}", to, e.getMessage()); 46 | } 47 | } 48 | LOGGER.info("send {} mails, {} succeed", toList.size(), succeedSendCount); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/com/njfu/ia/sys/service/impl/CropServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.sys.service.impl; 2 | 3 | import com.njfu.ia.sys.domain.Crop; 4 | import com.njfu.ia.sys.exception.BusinessException; 5 | import com.njfu.ia.sys.mapper.CropMapper; 6 | import com.njfu.ia.sys.service.CropService; 7 | import org.springframework.stereotype.Service; 8 | 9 | import javax.annotation.Resource; 10 | import java.util.List; 11 | 12 | @Service 13 | public class CropServiceImpl implements CropService { 14 | 15 | @Resource 16 | private CropMapper cropMapper; 17 | 18 | /** 19 | * 获取作物列表 20 | * 21 | * @param crop 22 | * @return 23 | */ 24 | @Override 25 | public List queryCrops(Crop crop) { 26 | return cropMapper.selectCrops(crop); 27 | } 28 | 29 | /** 30 | * 新增作物信息 31 | * 32 | * @param crop 33 | */ 34 | @Override 35 | public void addCrop(Crop crop) { 36 | int res = cropMapper.insertCrop(crop); 37 | if (res <= 0) { 38 | throw new BusinessException("新增作物信息失败"); 39 | } 40 | } 41 | 42 | /** 43 | * 修改作物信息 44 | * 45 | * @param crop 46 | */ 47 | @Override 48 | public void modifyCrop(Crop crop) { 49 | int res = cropMapper.updateCrop(crop); 50 | if (res <= 0) { 51 | throw new BusinessException("修改作物信息失败!"); 52 | } 53 | } 54 | 55 | /** 56 | * 删除作物信息 57 | * 58 | * @param crop 59 | */ 60 | @Override 61 | public void removeCrop(Crop crop) { 62 | int res = cropMapper.deleteCrop(crop); 63 | if (res <= 0) { 64 | throw new BusinessException("删除作物信息失败!"); 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /IA-PCS/src/main/java/com/njfu/ia/process/jms/consumer/UpstreamDataMessageConsumer.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.process.jms.consumer; 2 | 3 | import com.njfu.ia.process.service.UpstreamService; 4 | import com.njfu.ia.process.utils.Constants; 5 | import org.slf4j.Logger; 6 | import org.slf4j.LoggerFactory; 7 | import org.springframework.jms.annotation.JmsListener; 8 | import org.springframework.jms.annotation.JmsListeners; 9 | import org.springframework.stereotype.Component; 10 | 11 | import javax.annotation.Resource; 12 | import javax.jms.JMSException; 13 | import javax.jms.Message; 14 | import javax.jms.TextMessage; 15 | 16 | /** 17 | * 上行数据消费者 18 | */ 19 | @Component 20 | public class UpstreamDataMessageConsumer { 21 | 22 | private static final Logger LOGGER = LoggerFactory.getLogger(UpstreamDataMessageConsumer.class); 23 | 24 | @Resource 25 | private UpstreamService upstreamService; 26 | 27 | @JmsListeners( 28 | value = { 29 | @JmsListener(destination = Constants.QUEUE_UPSTREAM_HEART, concurrency = Constants.DEFAULT_CONCURRENCY_RANGE), 30 | @JmsListener(destination = Constants.QUEUE_UPSTREAM_DATA, concurrency = Constants.DEFAULT_CONCURRENCY_RANGE), 31 | } 32 | ) 33 | public void onMessage(Message message) { 34 | try { 35 | if (message instanceof TextMessage) { 36 | String messageText = ((TextMessage) message).getText(); 37 | // 处理上行数据 38 | upstreamService.consumeUpstreamMessage(messageText); 39 | LOGGER.info("UpstreamDataMessageConsumer consume message: {}", messageText); 40 | } 41 | } catch (JMSException e) { 42 | LOGGER.error("UpstreamDataMessageConsumer Exception", e); 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/com/njfu/ia/sys/domain/Machine.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.sys.domain; 2 | 3 | /** 4 | * 机械 5 | */ 6 | public class Machine { 7 | 8 | private String machineId; 9 | 10 | private String machineType; 11 | 12 | private Block block; 13 | 14 | private String useStatus; 15 | 16 | private String machinePs; 17 | 18 | public Machine() { 19 | } 20 | 21 | public String getMachineId() { 22 | return machineId; 23 | } 24 | 25 | public void setMachineId(String machineId) { 26 | this.machineId = machineId; 27 | } 28 | 29 | public String getMachineType() { 30 | return machineType; 31 | } 32 | 33 | public void setMachineType(String machineType) { 34 | this.machineType = machineType; 35 | } 36 | 37 | public Block getBlock() { 38 | return block; 39 | } 40 | 41 | public void setBlock(Block block) { 42 | this.block = block; 43 | } 44 | 45 | public String getUseStatus() { 46 | return useStatus; 47 | } 48 | 49 | public void setUseStatus(String useStatus) { 50 | this.useStatus = useStatus; 51 | } 52 | 53 | public String getMachinePs() { 54 | return machinePs; 55 | } 56 | 57 | public void setMachinePs(String machinePs) { 58 | this.machinePs = machinePs; 59 | } 60 | 61 | @Override 62 | public String toString() { 63 | return "Machine{" + 64 | "machineId='" + machineId + '\'' + 65 | ", machineType='" + machineType + '\'' + 66 | ", block=" + block + 67 | ", useStatus='" + useStatus + '\'' + 68 | ", machinePs='" + machinePs + '\'' + 69 | '}'; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/test/java/com/njfu/ia/sys/mapper/CropMapperTest.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.sys.mapper; 2 | 3 | import com.njfu.ia.sys.domain.Crop; 4 | import org.junit.Assert; 5 | import org.junit.Test; 6 | import org.junit.runner.RunWith; 7 | import org.slf4j.Logger; 8 | import org.slf4j.LoggerFactory; 9 | import org.springframework.boot.test.context.SpringBootTest; 10 | import org.springframework.test.context.junit4.SpringRunner; 11 | import org.springframework.transaction.annotation.Transactional; 12 | 13 | import javax.annotation.Resource; 14 | import java.util.List; 15 | 16 | @RunWith(SpringRunner.class) 17 | @SpringBootTest 18 | @Transactional 19 | public class CropMapperTest { 20 | 21 | private static final Logger LOGGER = LoggerFactory.getLogger(CropMapperTest.class); 22 | 23 | @Resource 24 | private CropMapper cropMapper; 25 | 26 | @Test 27 | public void selectCrops() throws Exception { 28 | List crops = cropMapper.selectCrops(new Crop()); 29 | LOGGER.info("crops: {}", crops); 30 | } 31 | 32 | @Test 33 | public void insertCrop() throws Exception { 34 | Crop crop = new Crop(); 35 | crop.setCropName("test"); 36 | 37 | int res = cropMapper.insertCrop(crop); 38 | Assert.assertEquals(1, res); 39 | } 40 | 41 | @Test 42 | public void updateCrop() throws Exception { 43 | Crop crop = new Crop(); 44 | crop.setCropName("test"); 45 | 46 | int res = cropMapper.updateCrop(crop); 47 | Assert.assertEquals(1, res); 48 | } 49 | 50 | @Test 51 | public void deleteCrop() throws Exception { 52 | Crop crop = new Crop(); 53 | 54 | int res = cropMapper.deleteCrop(crop); 55 | Assert.assertEquals(1, res); 56 | } 57 | 58 | } -------------------------------------------------------------------------------- /src/test/java/com/njfu/ia/sys/service/UpstreamDataRecordServiceTest.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.sys.service; 2 | 3 | import com.njfu.ia.sys.domain.ChartData; 4 | import com.njfu.ia.sys.domain.UpstreamDataRecord; 5 | import com.njfu.ia.sys.utils.JsonUtils; 6 | import org.junit.Test; 7 | import org.junit.runner.RunWith; 8 | import org.slf4j.Logger; 9 | import org.slf4j.LoggerFactory; 10 | import org.springframework.boot.test.context.SpringBootTest; 11 | import org.springframework.test.context.junit4.SpringRunner; 12 | import org.springframework.transaction.annotation.Transactional; 13 | 14 | import javax.annotation.Resource; 15 | import java.util.List; 16 | 17 | @RunWith(SpringRunner.class) 18 | @SpringBootTest 19 | @Transactional 20 | public class UpstreamDataRecordServiceTest { 21 | 22 | private static final Logger LOGGER = LoggerFactory.getLogger(UpstreamDataRecordServiceTest.class); 23 | 24 | @Resource 25 | private UpstreamDataRecordService upstreamDataRecordService; 26 | 27 | @Test 28 | public void getDataRecords() { 29 | List records = upstreamDataRecordService.queryDataRecords(new UpstreamDataRecord(), null, null); 30 | LOGGER.info("records: {}", JsonUtils.toJsonString(records)); 31 | } 32 | 33 | @Test 34 | public void getLastDataRecords() { 35 | List lastDataRecords = upstreamDataRecordService.queryLastDataRecords(1); 36 | LOGGER.info("data: {}", JsonUtils.toJsonString(lastDataRecords)); 37 | } 38 | 39 | @Test 40 | public void constructChartData() { 41 | ChartData chartData = upstreamDataRecordService.constructChartData(new Integer[]{1, 3, 5}, 16, null, null); 42 | LOGGER.info("chart data: {}", JsonUtils.toJsonString(chartData)); 43 | } 44 | } -------------------------------------------------------------------------------- /IA-LSN/src/main/java/com/njfu/ia/listener/connection/Connections.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.listener.connection; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | 6 | import java.io.OutputStream; 7 | import java.net.Socket; 8 | import java.util.Set; 9 | import java.util.concurrent.CopyOnWriteArraySet; 10 | 11 | /** 12 | * 处理socket连接 13 | */ 14 | public class Connections { 15 | 16 | private static final Logger LOGGER = LoggerFactory.getLogger(Connections.class); 17 | 18 | /** 19 | * socket连接集合 20 | */ 21 | private static Set CURRENT_CONNECT = new CopyOnWriteArraySet<>(); 22 | 23 | /** 24 | * 新增socket连接 25 | * 26 | * @param socket socket 27 | */ 28 | public static void join(Socket socket) { 29 | CURRENT_CONNECT.add(socket); 30 | LOGGER.info("new socket established, ip: {}", socket.getInetAddress()); 31 | } 32 | 33 | /** 34 | * 移除socket连接 35 | * 36 | * @param socket socket 37 | */ 38 | public static void kick(Socket socket) { 39 | CURRENT_CONNECT.remove(socket); 40 | } 41 | 42 | /** 43 | * 获取当前socket连接集合 44 | * 45 | * @return socket set 46 | */ 47 | public static Set list() { 48 | return CURRENT_CONNECT; 49 | } 50 | 51 | /** 52 | * 广播消息 53 | * 54 | * @param data data 55 | */ 56 | public static void broadcast(byte[] data) { 57 | for (Socket socket : CURRENT_CONNECT) { 58 | try (OutputStream os = socket.getOutputStream()) { 59 | os.write(data); 60 | os.flush(); 61 | } catch (Exception e) { 62 | LOGGER.error("write downstream data Exception", e); 63 | } 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/main/java/com/njfu/ia/sys/domain/Field.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.sys.domain; 2 | 3 | /** 4 | * 大棚 5 | */ 6 | public class Field { 7 | 8 | /** 9 | * 大棚编号 10 | */ 11 | private Integer id; 12 | 13 | /** 14 | * 大棚名称 15 | */ 16 | private String fieldName; 17 | 18 | /** 19 | * 所属区块编号 20 | */ 21 | private Integer sectionId; 22 | 23 | /** 24 | * 所属区块名称 25 | */ 26 | private String sectionName; 27 | 28 | /** 29 | * 种植作物编号 30 | */ 31 | private Integer cropId; 32 | 33 | /** 34 | * 种植作物名称 35 | */ 36 | private String cropName; 37 | 38 | public Field() { 39 | } 40 | 41 | public Integer getId() { 42 | return id; 43 | } 44 | 45 | public void setId(Integer id) { 46 | this.id = id; 47 | } 48 | 49 | public String getFieldName() { 50 | return fieldName; 51 | } 52 | 53 | public void setFieldName(String fieldName) { 54 | this.fieldName = fieldName; 55 | } 56 | 57 | public Integer getSectionId() { 58 | return sectionId; 59 | } 60 | 61 | public void setSectionId(Integer sectionId) { 62 | this.sectionId = sectionId; 63 | } 64 | 65 | public String getSectionName() { 66 | return sectionName; 67 | } 68 | 69 | public void setSectionName(String sectionName) { 70 | this.sectionName = sectionName; 71 | } 72 | 73 | public Integer getCropId() { 74 | return cropId; 75 | } 76 | 77 | public void setCropId(Integer cropId) { 78 | this.cropId = cropId; 79 | } 80 | 81 | public String getCropName() { 82 | return cropName; 83 | } 84 | 85 | public void setCropName(String cropName) { 86 | this.cropName = cropName; 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /src/main/java/com/njfu/ia/sys/service/impl/SectionServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.sys.service.impl; 2 | 3 | import com.njfu.ia.sys.domain.Section; 4 | import com.njfu.ia.sys.exception.BusinessException; 5 | import com.njfu.ia.sys.mapper.SectionMapper; 6 | import com.njfu.ia.sys.service.SectionService; 7 | import org.springframework.stereotype.Service; 8 | 9 | import javax.annotation.Resource; 10 | import java.util.List; 11 | 12 | @Service 13 | public class SectionServiceImpl implements SectionService { 14 | 15 | @Resource 16 | private SectionMapper sectionMapper; 17 | 18 | /** 19 | * 查询区块信息 20 | * 21 | * @param section 22 | * @return 23 | */ 24 | @Override 25 | public List
querySections(Section section) { 26 | return sectionMapper.selectSections(section); 27 | } 28 | 29 | /** 30 | * 新增区块信息 31 | * 32 | * @param section 33 | */ 34 | @Override 35 | public void addSection(Section section) { 36 | int count = sectionMapper.insertSection(section); 37 | if (count <= 0) { 38 | throw new BusinessException("新增区块信息失败!"); 39 | } 40 | } 41 | 42 | /** 43 | * 修改区块信息 44 | * 45 | * @param section 46 | */ 47 | @Override 48 | public void modifySection(Section section) { 49 | int count = sectionMapper.updateSection(section); 50 | if (count <= 0) { 51 | throw new BusinessException("修改区块信息失败!"); 52 | } 53 | } 54 | 55 | /** 56 | * 删除区块信息 57 | * 58 | * @param id 59 | */ 60 | @Override 61 | public void removeSection(Integer id) { 62 | int count = sectionMapper.deleteSection(id); 63 | if (count <= 0) { 64 | throw new BusinessException("删除区块信息失败!"); 65 | } 66 | } 67 | 68 | } 69 | -------------------------------------------------------------------------------- /src/main/java/com/njfu/ia/sys/domain/DataType.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.sys.domain; 2 | 3 | /** 4 | * 数据类型 5 | */ 6 | public class DataType { 7 | 8 | /** 9 | * 数据类型编号 10 | */ 11 | private Integer id; 12 | 13 | /** 14 | * 数据类型名称 15 | */ 16 | private String dataTypeName; 17 | 18 | /** 19 | * 数据类型缩写 20 | */ 21 | private String dataShortName; 22 | 23 | /** 24 | * 数据下限 25 | */ 26 | private Double floor; 27 | 28 | /** 29 | * 数据上限 30 | */ 31 | private Double ceil; 32 | 33 | /** 34 | * 使用状态 0,未使用 1,使用中 35 | */ 36 | private Integer useStatus; 37 | 38 | public DataType() { 39 | } 40 | 41 | public Integer getId() { 42 | return id; 43 | } 44 | 45 | public void setId(Integer id) { 46 | this.id = id; 47 | } 48 | 49 | public String getDataTypeName() { 50 | return dataTypeName; 51 | } 52 | 53 | public void setDataTypeName(String dataTypeName) { 54 | this.dataTypeName = dataTypeName; 55 | } 56 | 57 | public String getDataShortName() { 58 | return dataShortName; 59 | } 60 | 61 | public void setDataShortName(String dataShortName) { 62 | this.dataShortName = dataShortName; 63 | } 64 | 65 | public Double getFloor() { 66 | return floor; 67 | } 68 | 69 | public void setFloor(Double floor) { 70 | this.floor = floor; 71 | } 72 | 73 | public Double getCeil() { 74 | return ceil; 75 | } 76 | 77 | public void setCeil(Double ceil) { 78 | this.ceil = ceil; 79 | } 80 | 81 | public Integer getUseStatus() { 82 | return useStatus; 83 | } 84 | 85 | public void setUseStatus(Integer useStatus) { 86 | this.useStatus = useStatus; 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /src/main/java/com/njfu/ia/sys/domain/Memo.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.sys.domain; 2 | 3 | import com.fasterxml.jackson.annotation.JsonFormat; 4 | import com.njfu.ia.sys.utils.Constants; 5 | 6 | import java.util.Date; 7 | 8 | /** 9 | * 记录 10 | */ 11 | public class Memo { 12 | 13 | private Integer id; 14 | 15 | /** 16 | * 标题 17 | */ 18 | private String title; 19 | 20 | /** 21 | * 类型 22 | */ 23 | private Integer type; 24 | 25 | /** 26 | * 内容 27 | */ 28 | private String content; 29 | 30 | /** 31 | * 更新人 32 | */ 33 | private String updateUser; 34 | 35 | /** 36 | * 更新时间 37 | */ 38 | @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = Constants.DEFAULT_GMT) 39 | private Date updateTime; 40 | 41 | public Integer getId() { 42 | return id; 43 | } 44 | 45 | public void setId(Integer id) { 46 | this.id = id; 47 | } 48 | 49 | public String getTitle() { 50 | return title; 51 | } 52 | 53 | public void setTitle(String title) { 54 | this.title = title; 55 | } 56 | 57 | public Integer getType() { 58 | return type; 59 | } 60 | 61 | public void setType(Integer type) { 62 | this.type = type; 63 | } 64 | 65 | public String getContent() { 66 | return content; 67 | } 68 | 69 | public void setContent(String content) { 70 | this.content = content; 71 | } 72 | 73 | public String getUpdateUser() { 74 | return updateUser; 75 | } 76 | 77 | public void setUpdateUser(String updateUser) { 78 | this.updateUser = updateUser; 79 | } 80 | 81 | public Date getUpdateTime() { 82 | return updateTime; 83 | } 84 | 85 | public void setUpdateTime(Date updateTime) { 86 | this.updateTime = updateTime; 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /src/main/java/com/njfu/ia/sys/service/impl/FieldServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.sys.service.impl; 2 | 3 | import com.njfu.ia.sys.domain.Field; 4 | import com.njfu.ia.sys.exception.BusinessException; 5 | import com.njfu.ia.sys.mapper.FieldMapper; 6 | import com.njfu.ia.sys.mapper.SensorMapper; 7 | import com.njfu.ia.sys.service.FieldService; 8 | import org.springframework.stereotype.Service; 9 | 10 | import javax.annotation.Resource; 11 | import java.util.List; 12 | 13 | @Service 14 | public class FieldServiceImpl implements FieldService { 15 | 16 | @Resource 17 | private FieldMapper fieldMapper; 18 | 19 | @Resource 20 | private SensorMapper sensorMapper; 21 | 22 | /** 23 | * 获取大棚列表 24 | * 25 | * @param field 26 | * @return 27 | */ 28 | @Override 29 | public List queryFields(Field field) { 30 | return fieldMapper.selectFields(field); 31 | } 32 | 33 | /** 34 | * 新增大棚信息 35 | * 36 | * @param field 37 | */ 38 | @Override 39 | public void addField(Field field) { 40 | int addField = fieldMapper.insertField(field); 41 | if (addField <= 0) { 42 | throw new BusinessException("新增大棚信息失败!"); 43 | } 44 | } 45 | 46 | /** 47 | * 修改大棚信息 48 | * 49 | * @param field 50 | */ 51 | @Override 52 | public void modifyField(Field field) { 53 | int res = fieldMapper.updateField(field); 54 | if (res <= 0) { 55 | throw new BusinessException("修改大棚信息失败!"); 56 | } 57 | } 58 | 59 | /** 60 | * 删除大棚信息 61 | * 62 | * @param id 63 | */ 64 | @Override 65 | public void removeField(Integer id) { 66 | int delField = fieldMapper.deleteField(id); 67 | if (delField <= 0) { 68 | throw new BusinessException("删除大棚信息失败!"); 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/test/java/com/njfu/ia/sys/service/CropServiceTest.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.sys.service; 2 | 3 | import com.njfu.ia.sys.domain.Crop; 4 | import org.junit.Test; 5 | import org.junit.runner.RunWith; 6 | import org.slf4j.Logger; 7 | import org.slf4j.LoggerFactory; 8 | import org.springframework.boot.test.context.SpringBootTest; 9 | import org.springframework.test.context.junit4.SpringRunner; 10 | import org.springframework.transaction.annotation.Transactional; 11 | 12 | import javax.annotation.Resource; 13 | import java.util.List; 14 | 15 | @RunWith(SpringRunner.class) 16 | @SpringBootTest 17 | @Transactional 18 | public class CropServiceTest { 19 | 20 | private static final Logger LOGGER = LoggerFactory.getLogger(CropServiceTest.class); 21 | 22 | @Resource 23 | private CropService cropService; 24 | 25 | @Test 26 | public void getCrops() throws Exception { 27 | List crops = cropService.queryCrops(new Crop()); 28 | LOGGER.info("crops: {}", crops); 29 | } 30 | 31 | @Test 32 | public void addCrop() throws Exception { 33 | Crop crop = new Crop(); 34 | crop.setCropName("test"); 35 | 36 | try { 37 | cropService.addCrop(crop); 38 | } catch (Exception e) { 39 | e.printStackTrace(); 40 | } 41 | } 42 | 43 | @Test 44 | public void modifyCrop() throws Exception { 45 | Crop crop = new Crop(); 46 | crop.setCropName("test"); 47 | 48 | try { 49 | cropService.modifyCrop(crop); 50 | } catch (Exception e) { 51 | e.printStackTrace(); 52 | } 53 | } 54 | 55 | @Test 56 | public void removeCrop() throws Exception { 57 | Crop crop = new Crop(); 58 | 59 | try { 60 | cropService.removeCrop(crop); 61 | } catch (Exception e) { 62 | e.printStackTrace(); 63 | } 64 | } 65 | 66 | } -------------------------------------------------------------------------------- /src/main/resources/templates/sys/memo/memo.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | <#include "/common/standard.html"/> 6 | 备忘管理 7 | 8 | 9 |
10 | 11 | <#include "/common/topNav.html"/> 12 | 13 | 14 | <#include "/sys/sysSideNav.html"/> 15 | 16 | 17 |
18 |
19 | 22 | 23 |
24 | 28 |
29 | 30 |
31 | 42 |
43 |
44 |
    45 |
46 |
47 |
48 |
49 |
50 |
51 | 52 |
53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /IA-PCS/src/main/java/com/njfu/ia/process/jms/JmsSender.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.process.jms; 2 | 3 | import com.njfu.ia.process.utils.Constants; 4 | import org.springframework.jms.core.JmsMessagingTemplate; 5 | import org.springframework.stereotype.Service; 6 | 7 | import javax.annotation.Resource; 8 | import javax.jms.Destination; 9 | import javax.jms.Queue; 10 | import javax.jms.Topic; 11 | 12 | /** 13 | * 消息发送工具 14 | */ 15 | @Service 16 | public class JmsSender { 17 | 18 | /** 19 | * 上线通知/心跳反馈 20 | */ 21 | @Resource 22 | private Queue upstreamHeart; 23 | 24 | /** 25 | * 数据上行 26 | */ 27 | @Resource 28 | private Queue upstreamData; 29 | 30 | /** 31 | * 下行心跳反馈 32 | */ 33 | @Resource 34 | private Topic downstreamHeart; 35 | 36 | /** 37 | * 心跳失联通知 38 | */ 39 | @Resource 40 | private Queue informHeart; 41 | 42 | /** 43 | * 报警通知 44 | */ 45 | @Resource 46 | private Queue informAlarm; 47 | 48 | @Resource 49 | private JmsMessagingTemplate jmsMessagingTemplate; 50 | 51 | /** 52 | * 推送消息 53 | * 54 | * @param msgType msgType 55 | * @param message message 56 | */ 57 | public void sendMessage(int msgType, String message) { 58 | Destination destination = null; 59 | switch (msgType) { 60 | case Constants.MESSAGE_DOWNSTREAM_HEART: 61 | destination = downstreamHeart; 62 | break; 63 | case Constants.MESSAGE_INFORM_ON: 64 | case Constants.MESSAGE_INFORM_HEART: 65 | destination = informHeart; 66 | break; 67 | case Constants.MESSAGE_INFORM_ALARM: 68 | destination = informAlarm; 69 | break; 70 | default: 71 | break; 72 | } 73 | if (null != destination) { 74 | jmsMessagingTemplate.convertAndSend(destination, message); 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /IA-PCS/src/main/resources/mapper/EndDeviceMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 15 | 16 | 17 | UPDATE end_device 18 | 19 | 20 | model = #{model} 21 | 22 | 23 | mac = #{mac} 24 | 25 | 26 | section_id = #{sectionId} 27 | 28 | 29 | use_status = #{useStatus} 30 | 31 | 32 | WHERE id = #{deviceId} 33 | 34 | 35 | 50 | 51 | 52 | UPDATE end_device 53 | SET use_status = #{useStatus} 54 | WHERE id IN 55 | 56 | #{deviceId} 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /src/test/java/com/njfu/ia/sys/mapper/FieldMapperTest.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.sys.mapper; 2 | 3 | import com.njfu.ia.sys.domain.Block; 4 | import com.njfu.ia.sys.domain.Crop; 5 | import com.njfu.ia.sys.domain.Field; 6 | import org.junit.Assert; 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | import org.slf4j.Logger; 10 | import org.slf4j.LoggerFactory; 11 | import org.springframework.boot.test.context.SpringBootTest; 12 | import org.springframework.test.context.junit4.SpringRunner; 13 | import org.springframework.transaction.annotation.Transactional; 14 | 15 | import javax.annotation.Resource; 16 | import java.util.List; 17 | 18 | @RunWith(SpringRunner.class) 19 | @SpringBootTest 20 | @Transactional 21 | public class FieldMapperTest { 22 | 23 | private static final Logger LOGGER = LoggerFactory.getLogger(FieldMapperTest.class); 24 | 25 | @Resource 26 | private FieldMapper fieldMapper; 27 | 28 | @Test 29 | public void selectFields() throws Exception { 30 | Field field = new Field(); 31 | 32 | List fields = fieldMapper.selectFields(field); 33 | LOGGER.info("fields: {}", fields); 34 | } 35 | 36 | @Test 37 | public void insertField() throws Exception { 38 | Field field = new Field(); 39 | field.setFieldName("test"); 40 | 41 | Block block = new Block(); 42 | 43 | int res = fieldMapper.insertField(field); 44 | 45 | Assert.assertEquals(1, res); 46 | } 47 | 48 | @Test 49 | public void updateField() throws Exception { 50 | Field field = new Field(); 51 | field.setFieldName("test"); 52 | 53 | Block block = new Block(); 54 | 55 | int res = fieldMapper.updateField(field); 56 | Assert.assertEquals(1, res); 57 | } 58 | 59 | @Test 60 | public void deleteField() throws Exception { 61 | int res = fieldMapper.deleteField(1); 62 | 63 | Assert.assertEquals(1, res); 64 | } 65 | 66 | } -------------------------------------------------------------------------------- /src/main/java/com/njfu/ia/sys/service/impl/DataTypeServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.sys.service.impl; 2 | 3 | import com.njfu.ia.sys.domain.DataType; 4 | import com.njfu.ia.sys.exception.BusinessException; 5 | import com.njfu.ia.sys.mapper.DataTypeMapper; 6 | import com.njfu.ia.sys.service.DataTypeService; 7 | import com.njfu.ia.sys.utils.Constants; 8 | import org.springframework.stereotype.Service; 9 | 10 | import javax.annotation.Resource; 11 | import java.util.List; 12 | 13 | @Service 14 | public class DataTypeServiceImpl implements DataTypeService { 15 | 16 | @Resource 17 | private DataTypeMapper dataTypeMapper; 18 | 19 | /** 20 | * 查询数据类型 21 | * 22 | * @param dataType 23 | * @return 24 | */ 25 | @Override 26 | public List queryDataTypes(DataType dataType) { 27 | return dataTypeMapper.selectDataTypes(dataType); 28 | } 29 | 30 | /** 31 | * 新增数据类型 32 | * 33 | * @param dataType 34 | */ 35 | @Override 36 | public void addDataType(DataType dataType) { 37 | // 默认监控中状态 38 | dataType.setUseStatus(Constants.IN_USE_STATUS); 39 | int count = dataTypeMapper.insertDataType(dataType); 40 | if (count <= 0) { 41 | throw new RuntimeException("新增数据类型失败!"); 42 | } 43 | } 44 | 45 | /** 46 | * 更新数据类型 47 | * 48 | * @param dataType dataType 49 | */ 50 | @Override 51 | public void updateDataType(DataType dataType) { 52 | int count = dataTypeMapper.updateDataType(dataType); 53 | if (count <= 0) { 54 | throw new BusinessException("更新数据类型失败!"); 55 | } 56 | } 57 | 58 | /** 59 | * 删除数据类型 60 | * 61 | * @param id 62 | */ 63 | @Override 64 | public void reomveDataType(Integer id) { 65 | int count = dataTypeMapper.deleteDataType(id); 66 | if (count <= 0) { 67 | throw new RuntimeException("删除数据类型失败"); 68 | } 69 | } 70 | 71 | } 72 | -------------------------------------------------------------------------------- /IA-PCS/src/main/java/com/njfu/ia/process/domain/UpstreamDataRecord.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.process.domain; 2 | 3 | import com.fasterxml.jackson.annotation.JsonFormat; 4 | 5 | import java.util.Date; 6 | 7 | /** 8 | * 上行数据记录 9 | */ 10 | public class UpstreamDataRecord { 11 | 12 | /** 13 | * 记录编号 14 | */ 15 | private Integer id; 16 | 17 | /** 18 | * 来源终端设备编号 19 | */ 20 | private Integer deviceId; 21 | 22 | /** 23 | * 数据类型 24 | */ 25 | private Integer dataType; 26 | 27 | /** 28 | * 数据值 29 | */ 30 | private Double value; 31 | 32 | /** 33 | * 上传时间 34 | */ 35 | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") 36 | private Date receiveTime; 37 | 38 | /** 39 | * 记录时间 40 | */ 41 | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") 42 | private Date recordTime; 43 | 44 | public UpstreamDataRecord() { 45 | } 46 | 47 | public Integer getId() { 48 | return id; 49 | } 50 | 51 | public void setId(Integer id) { 52 | this.id = id; 53 | } 54 | 55 | public Integer getDeviceId() { 56 | return deviceId; 57 | } 58 | 59 | public void setDeviceId(Integer deviceId) { 60 | this.deviceId = deviceId; 61 | } 62 | 63 | public Integer getDataType() { 64 | return dataType; 65 | } 66 | 67 | public void setDataType(Integer dataType) { 68 | this.dataType = dataType; 69 | } 70 | 71 | public Double getValue() { 72 | return value; 73 | } 74 | 75 | public void setValue(Double value) { 76 | this.value = value; 77 | } 78 | 79 | public Date getReceiveTime() { 80 | return receiveTime; 81 | } 82 | 83 | public void setReceiveTime(Date receiveTime) { 84 | this.receiveTime = receiveTime; 85 | } 86 | 87 | public Date getRecordTime() { 88 | return recordTime; 89 | } 90 | 91 | public void setRecordTime(Date recordTime) { 92 | this.recordTime = recordTime; 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /src/test/java/com/njfu/ia/sys/mapper/BlockMapperTest.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.sys.mapper; 2 | 3 | 4 | import com.njfu.ia.sys.domain.Block; 5 | import com.njfu.ia.sys.utils.JsonUtils; 6 | import org.junit.Assert; 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | import org.slf4j.Logger; 10 | import org.slf4j.LoggerFactory; 11 | import org.springframework.boot.test.context.SpringBootTest; 12 | import org.springframework.test.context.junit4.SpringRunner; 13 | import org.springframework.transaction.annotation.Transactional; 14 | 15 | import javax.annotation.Resource; 16 | import java.util.List; 17 | 18 | @RunWith(SpringRunner.class) 19 | @SpringBootTest 20 | @Transactional 21 | public class BlockMapperTest { 22 | 23 | private static final Logger LOGGER = LoggerFactory.getLogger(BlockMapperTest.class); 24 | 25 | @Resource 26 | private BlockMapper blockMapper; 27 | 28 | @Test 29 | public void selectBlocks() throws Exception { 30 | List blocks = blockMapper.selectBlocks(new Block()); 31 | LOGGER.info("blocks: {}", blocks); 32 | } 33 | 34 | @Test 35 | public void selectBlocksWithSections() throws Exception { 36 | List blocks = blockMapper.selectBlocksWithSections(); 37 | LOGGER.info("blocks: {}", JsonUtils.toJsonString(blocks)); 38 | } 39 | 40 | @Test 41 | public void insertBlock() throws Exception { 42 | Block block = new Block(); 43 | 44 | int res = blockMapper.insertBlock(block); 45 | Assert.assertEquals(1, res); 46 | } 47 | 48 | @Test 49 | public void updateBlock() throws Exception { 50 | Block block = new Block(); 51 | block.setBlockName("test"); 52 | 53 | int res = blockMapper.updateBlock(block); 54 | Assert.assertEquals(1, res); 55 | } 56 | 57 | @Test 58 | public void deleteBlock() throws Exception { 59 | Block block = new Block(); 60 | 61 | int res = blockMapper.deleteBlock(1); 62 | Assert.assertEquals(1, res); 63 | } 64 | 65 | } -------------------------------------------------------------------------------- /src/test/java/com/njfu/ia/sys/service/FieldServiceTest.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.sys.service; 2 | 3 | import com.njfu.ia.sys.domain.Block; 4 | import com.njfu.ia.sys.domain.Field; 5 | import org.junit.Test; 6 | import org.junit.runner.RunWith; 7 | import org.slf4j.Logger; 8 | import org.slf4j.LoggerFactory; 9 | import org.springframework.boot.test.context.SpringBootTest; 10 | import org.springframework.test.context.junit4.SpringRunner; 11 | import org.springframework.transaction.annotation.Transactional; 12 | 13 | import javax.annotation.Resource; 14 | import java.util.List; 15 | 16 | @RunWith(SpringRunner.class) 17 | @SpringBootTest 18 | @Transactional 19 | public class FieldServiceTest { 20 | 21 | private static final Logger LOGGER = LoggerFactory.getLogger(FieldServiceTest.class); 22 | 23 | @Resource 24 | private FieldService fieldService; 25 | 26 | @Test 27 | public void getFields() throws Exception { 28 | List fields = fieldService.queryFields(new Field()); 29 | LOGGER.info("fields: {}", fields); 30 | } 31 | 32 | @Test 33 | public void addField() throws Exception { 34 | Field field = new Field(); 35 | field.setFieldName("test"); 36 | 37 | Block block = new Block(); 38 | 39 | try { 40 | fieldService.addField(field); 41 | } catch (Exception e) { 42 | e.printStackTrace(); 43 | } 44 | } 45 | 46 | 47 | @Test 48 | public void modifyField() throws Exception { 49 | Field field = new Field(); 50 | field.setFieldName("test"); 51 | 52 | Block block = new Block(); 53 | 54 | try { 55 | fieldService.modifyField(new Field()); 56 | } catch (Exception e) { 57 | e.printStackTrace(); 58 | } 59 | } 60 | 61 | @Test 62 | public void removeField() throws Exception { 63 | 64 | try { 65 | fieldService.removeField(1); 66 | } catch (Exception e) { 67 | e.printStackTrace(); 68 | } 69 | } 70 | } -------------------------------------------------------------------------------- /src/main/java/com/njfu/ia/sys/service/impl/IrrigationPlanServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.sys.service.impl; 2 | 3 | import com.njfu.ia.sys.domain.IrrigationPlan; 4 | import com.njfu.ia.sys.exception.BusinessException; 5 | import com.njfu.ia.sys.mapper.IrrigationPlanMapper; 6 | import com.njfu.ia.sys.service.IrrigationPlanService; 7 | import org.springframework.stereotype.Service; 8 | 9 | import javax.annotation.Resource; 10 | import java.util.List; 11 | 12 | @Service 13 | public class IrrigationPlanServiceImpl implements IrrigationPlanService { 14 | 15 | @Resource 16 | private IrrigationPlanMapper irrigationPlanMapper; 17 | 18 | /** 19 | * 获取灌溉方案列表 20 | * 21 | * @param irrigationPlan 22 | * @return 23 | */ 24 | @Override 25 | public List queryIrrigationPlans(IrrigationPlan irrigationPlan) { 26 | return irrigationPlanMapper.selectIrrigationPlans(irrigationPlan); 27 | } 28 | 29 | /** 30 | * 新增灌溉方案 31 | * 32 | * @param irrigationPlan 33 | */ 34 | @Override 35 | public void addIrrigationPlan(IrrigationPlan irrigationPlan) { 36 | int count = irrigationPlanMapper.insertIrrigationPlan(irrigationPlan); 37 | if (count <= 0) { 38 | throw new BusinessException("新增灌溉方案失败!"); 39 | } 40 | } 41 | 42 | /** 43 | * 修改灌溉方案 44 | * 45 | * @param irrigationPlan 46 | */ 47 | @Override 48 | public void modifyIrrigationPlan(IrrigationPlan irrigationPlan) { 49 | int count = irrigationPlanMapper.updateIrrigationPlan(irrigationPlan); 50 | if (count <= 0) { 51 | throw new BusinessException("修改灌溉方案失败!"); 52 | } 53 | } 54 | 55 | /** 56 | * 删除灌溉方案 57 | * 58 | * @param id 59 | */ 60 | @Override 61 | public void removeIrrigationPlan(Integer id) { 62 | int count = irrigationPlanMapper.deleteIrrigationPlan(id); 63 | if (count <= 0) { 64 | throw new BusinessException("删除灌溉方案失败!"); 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/main/resources/static/js/login.js: -------------------------------------------------------------------------------- 1 | var login = { 2 | init: function () { 3 | login.getUser(); 4 | login.ajaxLogin(); 5 | $('#error-message').hide(); 6 | 7 | var height = $(window).height(); 8 | if (height < 600) { 9 | $('.content').css({ 10 | 'position': 'relative', 11 | 'min-height': '600px' 12 | }) 13 | } 14 | }, 15 | /** 16 | * 查询用户事件 17 | */ 18 | getUser: function () { 19 | $.ajax({ 20 | url: 'sys/user/info', 21 | success: function (res) { 22 | if (res.code == 201) { 23 | window.location.href = 'sys'; 24 | } 25 | } 26 | }); 27 | }, 28 | /** 29 | * 触发登录事件 30 | */ 31 | ajaxLogin: function () { 32 | $('#submit').click(function () { 33 | $.ajax({ 34 | url: 'login', 35 | type: 'POST', 36 | data: { 37 | username: $('#username').val().trim(), 38 | password: $('#password').val().trim() 39 | }, 40 | success: function (res) { 41 | if (res.success) { 42 | window.location.href = 'sys' 43 | } else { 44 | var message = '登录失败!'; 45 | if (res.message) { 46 | message = res.message; 47 | } 48 | login.popErrorMessage(message); 49 | } 50 | } 51 | }); 52 | }); 53 | }, 54 | /** 55 | * 登录失败弹出提示 56 | */ 57 | popErrorMessage: function (message) { 58 | $('#error-message') 59 | .text(message) 60 | .fadeIn(1000) 61 | .animate({top: '-135px'}) 62 | .delay(2400) 63 | .fadeOut(500) 64 | .css({top: '135px'}); 65 | } 66 | }; 67 | /** 68 | * 启动 69 | */ 70 | login.init(); -------------------------------------------------------------------------------- /src/main/java/com/njfu/ia/sys/web/IndexController.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.sys.web; 2 | 3 | import com.njfu.ia.sys.domain.User; 4 | import com.njfu.ia.sys.enums.ResultEnum; 5 | import com.njfu.ia.sys.service.BlockService; 6 | import com.njfu.ia.sys.utils.Constants; 7 | import com.njfu.ia.sys.utils.Result; 8 | import org.apache.shiro.SecurityUtils; 9 | import org.slf4j.Logger; 10 | import org.slf4j.LoggerFactory; 11 | import org.springframework.stereotype.Controller; 12 | import org.springframework.web.bind.annotation.GetMapping; 13 | import org.springframework.web.bind.annotation.RequestMapping; 14 | import org.springframework.web.bind.annotation.ResponseBody; 15 | 16 | import javax.annotation.Resource; 17 | 18 | @Controller 19 | @RequestMapping("/sys") 20 | public class IndexController { 21 | 22 | private static final Logger LOGGER = LoggerFactory.getLogger(IndexController.class); 23 | 24 | @Resource 25 | private BlockService blockService; 26 | 27 | /** 28 | * 系统管理首页 29 | * 30 | * @return Page 31 | */ 32 | @GetMapping("") 33 | public String index() { 34 | return "sys/index"; 35 | } 36 | 37 | /** 38 | * 获取用户名称信息 39 | * 40 | * @return name 41 | */ 42 | @GetMapping("/user/info") 43 | public @ResponseBody 44 | Result getUserInfo() { 45 | if (Constants.USE_SHIRO) { 46 | try { 47 | User user = (User) SecurityUtils.getSubject().getPrincipal(); 48 | String name = user.getName(); 49 | return Result.response(ResultEnum.DATA, name); 50 | } catch (Exception e) { 51 | LOGGER.error("Security get user info Exception", e); 52 | return Result.response(ResultEnum.FAIL); 53 | } 54 | } else { 55 | return Result.response(ResultEnum.FAIL); 56 | } 57 | } 58 | 59 | /** 60 | * 跳转个人设置页 61 | * 62 | * @return 63 | */ 64 | @GetMapping("/user") 65 | public String user() { 66 | return "sys/auth/user"; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /src/test/java/com/njfu/ia/sys/mapper/MemoMapperTest.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.sys.mapper; 2 | 3 | import com.njfu.ia.sys.domain.Memo; 4 | import org.junit.Assert; 5 | import org.junit.Test; 6 | import org.junit.runner.RunWith; 7 | import org.slf4j.Logger; 8 | import org.slf4j.LoggerFactory; 9 | import org.springframework.boot.test.context.SpringBootTest; 10 | import org.springframework.test.context.junit4.SpringRunner; 11 | import org.springframework.transaction.annotation.Transactional; 12 | 13 | import javax.annotation.Resource; 14 | import java.util.List; 15 | 16 | @RunWith(SpringRunner.class) 17 | @SpringBootTest 18 | @Transactional 19 | public class MemoMapperTest { 20 | 21 | private static final Logger LOGGER = LoggerFactory.getLogger(MemoMapperTest.class); 22 | @Resource 23 | private MemoMapper memoMapper; 24 | 25 | @Test 26 | public void selectMemoList() throws Exception { 27 | List memoList = memoMapper.selectMemoList(1); 28 | LOGGER.info("memoList: {}", memoList); 29 | } 30 | 31 | @Test 32 | public void selectMemo() throws Exception { 33 | Memo memo = memoMapper.selectMemo(1); 34 | LOGGER.info("memo: {}", memo); 35 | } 36 | 37 | @Test 38 | public void insertMemo() throws Exception { 39 | Memo memo = new Memo(); 40 | memo.setTitle("test"); 41 | memo.setType(1); 42 | memo.setContent("test"); 43 | memo.setUpdateUser("root"); 44 | int res = memoMapper.insertMemo(memo); 45 | Assert.assertEquals(1, res); 46 | } 47 | 48 | @Test 49 | public void updateMemo() throws Exception { 50 | Memo memo = new Memo(); 51 | memo.setId(1); 52 | memo.setTitle("test"); 53 | memo.setContent("test"); 54 | memo.setUpdateUser("root"); 55 | int res = memoMapper.updateMemo(memo); 56 | Assert.assertEquals(1, res); 57 | } 58 | 59 | @Test 60 | public void deleteMemo() throws Exception { 61 | int res = memoMapper.deleteMemo(1); 62 | Assert.assertEquals(1, res); 63 | } 64 | 65 | } -------------------------------------------------------------------------------- /src/main/resources/mapper/DataTypeMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 23 | 24 | 25 | INSERT INTO data_type (data_type_name, data_short_name, floor, ceil, use_status) 26 | VALUES (#{dataTypeName}, #{dataShortName}, #{floor}, #{ceil}, #{useStatus}) 27 | 28 | 29 | 30 | UPDATE data_type 31 | 32 | 33 | data_type_name = #{dataTypeName}, 34 | 35 | 36 | data_short_name = #{dataShortName}, 37 | 38 | 39 | floor = #{floor}, 40 | 41 | 42 | ceil = #{ceil}, 43 | 44 | 45 | use_status = #{useStatus} 46 | 47 | 48 | WHERE id = #{id} 49 | 50 | 51 | 52 | DELETE FROM data_type 53 | WHERE id = #{id} 54 | 55 | 56 | -------------------------------------------------------------------------------- /src/main/resources/mapper/AlarmRecordMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 38 | 39 | 40 | UPDATE alarm_record 41 | 42 | handle_flag = #{flag} 43 | 44 | WHERE id IN 45 | 46 | #{id} 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /src/main/resources/mapper/BlockMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 17 | 18 | 19 | INSERT INTO block (id, block_name, block_location) 20 | VALUES (#{id}, #{blockName}, #{blockLocation}) 21 | 22 | 23 | 24 | UPDATE block 25 | 26 | 27 | block_name = #{blockName}, 28 | 29 | 30 | block_location = #{blockLocation} 31 | 32 | 33 | WHERE id = #{id} 34 | 35 | 36 | 37 | DELETE FROM block 38 | WHERE id = #{id} 39 | 40 | 41 | 42 | 43 | 44 | 46 | 47 | 48 | 55 | 56 | 63 | 64 | -------------------------------------------------------------------------------- /src/test/java/com/njfu/ia/sys/mapper/IrrigationPlanMapperTest.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.sys.mapper; 2 | 3 | import com.njfu.ia.sys.domain.IrrigationPlan; 4 | import org.junit.Assert; 5 | import org.junit.Test; 6 | import org.junit.runner.RunWith; 7 | import org.slf4j.Logger; 8 | import org.slf4j.LoggerFactory; 9 | import org.springframework.boot.test.context.SpringBootTest; 10 | import org.springframework.test.context.junit4.SpringRunner; 11 | import org.springframework.transaction.annotation.Transactional; 12 | 13 | import javax.annotation.Resource; 14 | import java.util.List; 15 | 16 | @RunWith(SpringRunner.class) 17 | @SpringBootTest 18 | @Transactional 19 | public class IrrigationPlanMapperTest { 20 | 21 | @Resource 22 | private IrrigationPlanMapper irrigationPlanMapper; 23 | 24 | private static final Logger LOGGER = LoggerFactory.getLogger(IrrigationPlanMapperTest.class); 25 | 26 | @Test 27 | public void selectIrrigationPlans() throws Exception { 28 | IrrigationPlan irrigationPlan = new IrrigationPlan(); 29 | List irrigationPlans = irrigationPlanMapper.selectIrrigationPlans(irrigationPlan); 30 | LOGGER.info("irrigationPlans: {}", irrigationPlans); 31 | } 32 | 33 | @Test 34 | public void insertIrrigationPlan() throws Exception { 35 | IrrigationPlan irrigationPlan = new IrrigationPlan(); 36 | irrigationPlan.setPlanVolume(500D); 37 | irrigationPlan.setDuration(100); 38 | int count = irrigationPlanMapper.insertIrrigationPlan(irrigationPlan); 39 | Assert.assertEquals(1, count); 40 | } 41 | 42 | @Test 43 | public void updateIrrigationPlan() throws Exception { 44 | IrrigationPlan irrigationPlan = new IrrigationPlan(); 45 | irrigationPlan.setId(1); 46 | irrigationPlan.setPlanVolume(500D); 47 | int count = irrigationPlanMapper.updateIrrigationPlan(irrigationPlan); 48 | Assert.assertEquals(1, count); 49 | } 50 | 51 | @Test 52 | public void deleteIrrigationPlan() throws Exception { 53 | int count = irrigationPlanMapper.deleteIrrigationPlan(1); 54 | Assert.assertEquals(1, count); 55 | } 56 | 57 | } -------------------------------------------------------------------------------- /src/main/java/com/njfu/ia/sys/domain/User.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.sys.domain; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnore; 4 | 5 | /** 6 | * 用户 7 | */ 8 | public class User { 9 | 10 | /** 11 | * 用户编号 12 | */ 13 | private Integer id; 14 | 15 | /** 16 | * 用户名称 17 | */ 18 | private String name; 19 | 20 | /** 21 | * 账号 22 | */ 23 | private String username; 24 | 25 | /** 26 | * 邮箱地址 27 | */ 28 | private String mail; 29 | 30 | /** 31 | * 密码 32 | */ 33 | @JsonIgnore 34 | private String password; 35 | 36 | /** 37 | * 盐 38 | */ 39 | @JsonIgnore 40 | private String salt; 41 | 42 | /** 43 | * 账号状态 0-无效,1-有效 44 | */ 45 | private Integer status; 46 | 47 | public User() { 48 | } 49 | 50 | public Integer getId() { 51 | return id; 52 | } 53 | 54 | public void setId(Integer id) { 55 | this.id = id; 56 | } 57 | 58 | public String getName() { 59 | return name; 60 | } 61 | 62 | public void setName(String name) { 63 | this.name = name; 64 | } 65 | 66 | public String getUsername() { 67 | return username; 68 | } 69 | 70 | public void setUsername(String username) { 71 | this.username = username; 72 | } 73 | 74 | public String getMail() { 75 | return mail; 76 | } 77 | 78 | public void setMail(String mail) { 79 | this.mail = mail; 80 | } 81 | 82 | public String getPassword() { 83 | return password; 84 | } 85 | 86 | public void setPassword(String password) { 87 | this.password = password; 88 | } 89 | 90 | public String getSalt() { 91 | return salt; 92 | } 93 | 94 | public void setSalt(String salt) { 95 | this.salt = salt; 96 | } 97 | 98 | public Integer getStatus() { 99 | return status; 100 | } 101 | 102 | public void setStatus(Integer status) { 103 | this.status = status; 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /src/main/resources/mapper/FieldMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 23 | 24 | 25 | INSERT INTO field (field_name, section_id, crop_id) 26 | VALUES (#{fieldName}, #{sectionId}, #{cropId}) 27 | 28 | 29 | 30 | UPDATE field 31 | SET field_name = #{fieldName}, section_id = #{sectionId}, crop_id = #{crop.cropId} 32 | WHERE id = #{id} 33 | 34 | 35 | 36 | DELETE FROM field 37 | WHERE id = #{id} 38 | 39 | 40 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /src/test/java/com/njfu/ia/sys/service/BlockServiceTest.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.sys.service; 2 | 3 | import com.njfu.ia.sys.domain.Block; 4 | import com.njfu.ia.sys.utils.JsonUtils; 5 | import org.junit.Test; 6 | import org.junit.runner.RunWith; 7 | import org.slf4j.Logger; 8 | import org.slf4j.LoggerFactory; 9 | import org.springframework.boot.test.context.SpringBootTest; 10 | import org.springframework.test.context.junit4.SpringRunner; 11 | import org.springframework.transaction.annotation.Transactional; 12 | 13 | import javax.annotation.Resource; 14 | import java.util.List; 15 | 16 | @RunWith(SpringRunner.class) 17 | @SpringBootTest 18 | @Transactional 19 | public class BlockServiceTest { 20 | 21 | private static final Logger LOGGER = LoggerFactory.getLogger(BlockServiceTest.class); 22 | 23 | @Resource 24 | private BlockService blockService; 25 | 26 | @Test 27 | public void getBlocks() throws Exception { 28 | List blocks = blockService.queryBlocks(new Block()); 29 | LOGGER.info("blocks: {}", blocks); 30 | } 31 | 32 | @Test 33 | public void getBlocksWithSections() throws Exception { 34 | List blocksAndFields = blockService.queryBlocksWithSections(); 35 | LOGGER.info("blocksAndFields: {}", JsonUtils.toJsonString(blocksAndFields)); 36 | } 37 | 38 | @Test 39 | public void addBlock() throws Exception { 40 | Block block = new Block(); 41 | block.setBlockName("test"); 42 | 43 | try { 44 | blockService.addBlock(block); 45 | } catch (Exception e) { 46 | e.printStackTrace(); 47 | } 48 | } 49 | 50 | @Test 51 | public void modifyBlock() throws Exception { 52 | Block block = new Block(); 53 | block.setBlockName("test"); 54 | 55 | try { 56 | blockService.modifyBlock(block); 57 | } catch (Exception e) { 58 | e.printStackTrace(); 59 | } 60 | } 61 | 62 | @Test 63 | public void removeBlock() throws Exception { 64 | Block block = new Block(); 65 | 66 | try { 67 | blockService.removeBlock(1); 68 | } catch (Exception e) { 69 | e.printStackTrace(); 70 | } 71 | } 72 | 73 | } -------------------------------------------------------------------------------- /IA-PCS/src/main/java/com/njfu/ia/process/domain/DataType.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.process.domain; 2 | 3 | /** 4 | * 数据类型 5 | */ 6 | public class DataType { 7 | 8 | /** 9 | * 数据类型编号 10 | */ 11 | private Integer id; 12 | 13 | /** 14 | * 数据类型名称 15 | */ 16 | private String dataTypeName; 17 | 18 | /** 19 | * 数据类型缩写 20 | */ 21 | private String dataShortName; 22 | 23 | /** 24 | * 数据下限 25 | */ 26 | private Double floor; 27 | 28 | /** 29 | * 数据上限 30 | */ 31 | private Double ceil; 32 | 33 | /** 34 | * 使用状态 0,未使用 1,使用中 35 | */ 36 | private Integer useStatus; 37 | 38 | public DataType() { 39 | } 40 | 41 | public Integer getId() { 42 | return id; 43 | } 44 | 45 | public void setId(Integer id) { 46 | this.id = id; 47 | } 48 | 49 | public String getDataTypeName() { 50 | return dataTypeName; 51 | } 52 | 53 | public void setDataTypeName(String dataTypeName) { 54 | this.dataTypeName = dataTypeName; 55 | } 56 | 57 | public String getDataShortName() { 58 | return dataShortName; 59 | } 60 | 61 | public void setDataShortName(String dataShortName) { 62 | this.dataShortName = dataShortName; 63 | } 64 | 65 | public Double getFloor() { 66 | return floor; 67 | } 68 | 69 | public void setFloor(Double floor) { 70 | this.floor = floor; 71 | } 72 | 73 | public Double getCeil() { 74 | return ceil; 75 | } 76 | 77 | public void setCeil(Double ceil) { 78 | this.ceil = ceil; 79 | } 80 | 81 | public Integer getUseStatus() { 82 | return useStatus; 83 | } 84 | 85 | public void setUseStatus(Integer useStatus) { 86 | this.useStatus = useStatus; 87 | } 88 | 89 | @Override 90 | public String toString() { 91 | return "DataType{" + 92 | "id=" + id + 93 | ", dataTypeName='" + dataTypeName + '\'' + 94 | ", dataShortName='" + dataShortName + '\'' + 95 | ", floor=" + floor + 96 | ", ceil=" + ceil + 97 | ", useStatus=" + useStatus + 98 | '}'; 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /src/test/java/com/njfu/ia/sys/service/MemoServiceTest.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.sys.service; 2 | 3 | import com.njfu.ia.sys.domain.Memo; 4 | import com.njfu.ia.sys.exception.BusinessException; 5 | import org.junit.Test; 6 | import org.junit.runner.RunWith; 7 | import org.slf4j.Logger; 8 | import org.slf4j.LoggerFactory; 9 | import org.springframework.boot.test.context.SpringBootTest; 10 | import org.springframework.test.context.junit4.SpringRunner; 11 | import org.springframework.transaction.annotation.Transactional; 12 | 13 | import javax.annotation.Resource; 14 | import java.util.List; 15 | 16 | @RunWith(SpringRunner.class) 17 | @SpringBootTest 18 | @Transactional 19 | public class MemoServiceTest { 20 | 21 | private static final Logger LOGGER = LoggerFactory.getLogger(MemoServiceTest.class); 22 | @Resource 23 | private MemoService memoService; 24 | 25 | @Test 26 | public void getMemoList() throws Exception { 27 | List memoList = memoService.queryMemoList(1); 28 | LOGGER.info("memoList: {}", memoList); 29 | } 30 | 31 | @Test 32 | public void getMemo() throws Exception { 33 | Memo memo = memoService.queryMemo(1); 34 | LOGGER.info("memo: {}", memo); 35 | } 36 | 37 | @Test 38 | public void addMemo() throws Exception { 39 | Memo memo = new Memo(); 40 | memo.setTitle("test"); 41 | memo.setType(1); 42 | memo.setContent("test"); 43 | memo.setUpdateUser("root"); 44 | 45 | try { 46 | memoService.addMemo(memo); 47 | } catch (BusinessException e) { 48 | e.printStackTrace(); 49 | } 50 | } 51 | 52 | @Test 53 | public void modifyMemo() throws Exception { 54 | Memo memo = new Memo(); 55 | memo.setId(1); 56 | memo.setTitle("test"); 57 | memo.setUpdateUser("root"); 58 | 59 | try { 60 | memoService.modifyMemo(memo); 61 | } catch (BusinessException e) { 62 | e.printStackTrace(); 63 | } 64 | } 65 | 66 | @Test 67 | public void removeMemo() throws Exception { 68 | try { 69 | memoService.removeMemo(1); 70 | } catch (BusinessException e) { 71 | e.printStackTrace(); 72 | } 73 | } 74 | 75 | } -------------------------------------------------------------------------------- /src/main/resources/mapper/UpstreamDataRecordMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 31 | 32 | 41 | 42 | 54 | 55 | -------------------------------------------------------------------------------- /src/main/resources/templates/common/topNav.html: -------------------------------------------------------------------------------- 1 | 47 | 48 | -------------------------------------------------------------------------------- /src/main/resources/static/js/sys/index.js: -------------------------------------------------------------------------------- 1 | var index = { 2 | init: function () { 3 | $('.field-card').hover(function () { 4 | 5 | }, function () { 6 | $(this).popover('destroy'); 7 | }); 8 | }, 9 | appendStatus: function (data, fieldName) { 10 | var html = '
  • 区块编号: ' + '' + fieldName + '
  • '; 11 | $.each(data, function (i, el) { 12 | html += '
  • ' + el.dataTypeName + ':' + el.value + '
  • ' 13 | }); 14 | return html + '
'; 15 | }, 16 | /** 17 | * 发送ajax请求 18 | * @param url 19 | * @param method 20 | * @param params 21 | * @param callback 22 | */ 23 | sendRequest: function (url, method, params, callback) { 24 | $.ajax({ 25 | method: method, 26 | url: url, 27 | data: params, 28 | success: function (res) { 29 | if (undefined != callback) { 30 | callback(res); 31 | } 32 | } 33 | }); 34 | }, 35 | vm: new Vue({ 36 | el: '#wrapper', 37 | data: { 38 | blocks: [] 39 | }, 40 | mounted: function () { 41 | var that = this; 42 | this.$nextTick(function () { 43 | index.sendRequest('sys/file/block/section/list', 'GET', null, function (res) { 44 | that.blocks = res.data; 45 | index.init(); 46 | }); 47 | }); 48 | }, 49 | methods: { 50 | over: function ($event, sectionId, sectionName) { 51 | index.sendRequest('sys/data/status', 'GET', {sectionId: sectionId}, function (res) { 52 | $($event.target).popover('destroy').popover({ 53 | title: '区块名称:' + sectionName + '', 54 | placement: 'auto', 55 | html: true, 56 | content: index.appendStatus(res.data, sectionId) 57 | }).popover('show'); 58 | }); 59 | }, 60 | out: function () { 61 | $('.popover').prev().popover('destroy'); 62 | } 63 | } 64 | }) 65 | }; -------------------------------------------------------------------------------- /src/test/java/com/njfu/ia/sys/service/IrrigationPlanServiceTest.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.sys.service; 2 | 3 | import com.njfu.ia.sys.domain.IrrigationPlan; 4 | import org.junit.Test; 5 | import org.junit.runner.RunWith; 6 | import org.slf4j.Logger; 7 | import org.slf4j.LoggerFactory; 8 | import org.springframework.boot.test.context.SpringBootTest; 9 | import org.springframework.test.context.junit4.SpringRunner; 10 | import org.springframework.transaction.annotation.Transactional; 11 | 12 | import javax.annotation.Resource; 13 | import java.util.List; 14 | 15 | @RunWith(SpringRunner.class) 16 | @SpringBootTest 17 | @Transactional 18 | public class IrrigationPlanServiceTest { 19 | 20 | @Resource 21 | private IrrigationPlanService irrigationPlanService; 22 | 23 | private static final Logger LOGGER = LoggerFactory.getLogger(IrrigationPlanServiceTest.class); 24 | 25 | @Test 26 | public void getIrrigationPlans() throws Exception { 27 | IrrigationPlan irrigationPlan = new IrrigationPlan(); 28 | List irrigationPlans = irrigationPlanService.queryIrrigationPlans(irrigationPlan); 29 | LOGGER.info("irrigationPlans: {}", irrigationPlans); 30 | } 31 | 32 | @Test 33 | public void addIrrigationPlan() throws Exception { 34 | IrrigationPlan irrigationPlan = new IrrigationPlan(); 35 | irrigationPlan.setPlanVolume(500D); 36 | irrigationPlan.setDuration(100); 37 | 38 | try { 39 | irrigationPlanService.addIrrigationPlan(irrigationPlan); 40 | } catch (Exception e) { 41 | e.printStackTrace(); 42 | } 43 | } 44 | 45 | @Test 46 | public void modifyIrrigationPlan() throws Exception { 47 | IrrigationPlan irrigationPlan = new IrrigationPlan(); 48 | irrigationPlan.setId(1); 49 | irrigationPlan.setPlanVolume(500D); 50 | 51 | try { 52 | irrigationPlanService.modifyIrrigationPlan(irrigationPlan); 53 | } catch (Exception e) { 54 | e.printStackTrace(); 55 | } 56 | } 57 | 58 | @Test 59 | public void removeIrrigationPlan() throws Exception { 60 | try { 61 | irrigationPlanService.removeIrrigationPlan(1); 62 | } catch (Exception e) { 63 | e.printStackTrace(); 64 | } 65 | } 66 | 67 | } -------------------------------------------------------------------------------- /src/main/java/com/njfu/ia/sys/domain/Sensor.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.sys.domain; 2 | 3 | /** 4 | * 传感器 5 | */ 6 | public class Sensor { 7 | 8 | private String sensorId; 9 | 10 | private String sensorFunc; 11 | 12 | private String sensorType; 13 | 14 | private Field field; 15 | 16 | private String terminalId; 17 | 18 | private String useStatus; 19 | 20 | private String sensorPs; 21 | 22 | public Sensor() { 23 | } 24 | 25 | public String getSensorId() { 26 | return sensorId; 27 | } 28 | 29 | public void setSensorId(String sensorId) { 30 | this.sensorId = sensorId; 31 | } 32 | 33 | public String getSensorFunc() { 34 | return sensorFunc; 35 | } 36 | 37 | public void setSensorFunc(String sensorFunc) { 38 | this.sensorFunc = sensorFunc; 39 | } 40 | 41 | public String getSensorType() { 42 | return sensorType; 43 | } 44 | 45 | public void setSensorType(String sensorType) { 46 | this.sensorType = sensorType; 47 | } 48 | 49 | public Field getField() { 50 | return field; 51 | } 52 | 53 | public void setField(Field field) { 54 | this.field = field; 55 | } 56 | 57 | public String getTerminalId() { 58 | return terminalId; 59 | } 60 | 61 | public void setTerminalId(String terminalId) { 62 | this.terminalId = terminalId; 63 | } 64 | 65 | public String getUseStatus() { 66 | return useStatus; 67 | } 68 | 69 | public void setUseStatus(String useStatus) { 70 | this.useStatus = useStatus; 71 | } 72 | 73 | public String getSensorPs() { 74 | return sensorPs; 75 | } 76 | 77 | public void setSensorPs(String sensorPs) { 78 | this.sensorPs = sensorPs; 79 | } 80 | 81 | @Override 82 | public String toString() { 83 | return "Sensor{" + 84 | "sensorId='" + sensorId + '\'' + 85 | ", sensorFunc='" + sensorFunc + '\'' + 86 | ", sensorType='" + sensorType + '\'' + 87 | ", field=" + field + 88 | ", terminalId='" + terminalId + '\'' + 89 | ", useStatus='" + useStatus + '\'' + 90 | ", sensorPs='" + sensorPs + '\'' + 91 | '}'; 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /src/main/resources/mapper/MachineMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 34 | 35 | 36 | INSERT INTO machine (machine_id, machine_type, block_id, use_status, machine_ps) 37 | VALUES (#{machineId}, #{machineType}, #{block.blockId}, #{useStatus}, #{machinePs}) 38 | 39 | 40 | 41 | UPDATE machine 42 | SET machine_type = #{machineType}, block_id = #{block.blockId}, use_status = #{useStatus}, machine_ps = 43 | #{machinePs} 44 | WHERE machine_id = #{machineId} 45 | 46 | 47 | 48 | DELETE FROM machine 49 | WHERE machine_id = #{machineId} 50 | 51 | 52 | 53 | UPDATE machine 54 | SET block_id = NULL 55 | WHERE block_id = #{blockId} 56 | 57 | -------------------------------------------------------------------------------- /src/main/java/com/njfu/ia/sys/service/impl/BlockServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.sys.service.impl; 2 | 3 | import com.njfu.ia.sys.domain.*; 4 | import com.njfu.ia.sys.exception.BusinessException; 5 | import com.njfu.ia.sys.mapper.*; 6 | import com.njfu.ia.sys.service.BlockService; 7 | import org.springframework.stereotype.Service; 8 | import org.springframework.transaction.annotation.Transactional; 9 | 10 | import javax.annotation.Resource; 11 | import java.util.List; 12 | 13 | @Service 14 | public class BlockServiceImpl implements BlockService { 15 | 16 | @Resource 17 | private BlockMapper blockMapper; 18 | 19 | @Resource 20 | private FieldMapper fieldMapper; 21 | 22 | @Resource 23 | private MachineMapper machineMapper; 24 | 25 | @Resource 26 | private SensorMapper sensorMapper; 27 | 28 | /** 29 | * 获取地块列表 30 | * 31 | * @param block 32 | * @return data 33 | */ 34 | @Override 35 | public List queryBlocks(Block block) { 36 | return blockMapper.selectBlocks(block); 37 | } 38 | 39 | /** 40 | * 查询所有地块及各地块下处于使用中状态的区块 41 | * 42 | * @return data 43 | */ 44 | @Override 45 | public List queryBlocksWithSections() { 46 | return blockMapper.selectBlocksWithSections(); 47 | } 48 | 49 | /** 50 | * 新增地块信息 51 | * 52 | * @param block 53 | */ 54 | @Override 55 | public void addBlock(Block block) { 56 | // 若blockPs为空字符串,转为null 57 | 58 | int count = blockMapper.insertBlock(block); 59 | if (count <= 0) { 60 | throw new BusinessException("新增地块信息失败"); 61 | } 62 | } 63 | 64 | /** 65 | * 修改地块信息 66 | * 67 | * @param block 68 | */ 69 | @Override 70 | public void modifyBlock(Block block) { 71 | // 若blockPs为空字符串,转为null 72 | 73 | int res = blockMapper.updateBlock(block); 74 | if (res <= 0) { 75 | throw new BusinessException("修改地块信息失败!"); 76 | } 77 | } 78 | 79 | /** 80 | * 删除地块信息 81 | * 82 | * @param block blockId 83 | */ 84 | @Override 85 | @Transactional 86 | public void removeBlock(Integer id) { 87 | int count = blockMapper.deleteBlock(id); 88 | if (count <= 0) { 89 | throw new BusinessException("删除地块信息失败!"); 90 | } 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /src/main/java/com/njfu/ia/sys/service/impl/SensorServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.sys.service.impl; 2 | 3 | import com.njfu.ia.sys.domain.Field; 4 | import com.njfu.ia.sys.domain.Sensor; 5 | import com.njfu.ia.sys.exception.BusinessException; 6 | import com.njfu.ia.sys.mapper.SensorMapper; 7 | import com.njfu.ia.sys.service.SensorService; 8 | import org.springframework.stereotype.Service; 9 | 10 | import javax.annotation.Resource; 11 | import java.util.List; 12 | 13 | @Service 14 | public class SensorServiceImpl implements SensorService { 15 | 16 | @Resource 17 | private SensorMapper sensorMapper; 18 | 19 | /** 20 | * 获取传感器列表 21 | * 22 | * @param sensor 23 | * @param field 24 | * @return data 25 | */ 26 | @Override 27 | public List querySensors(Sensor sensor, Field field) { 28 | sensor.setField(field); 29 | return sensorMapper.selectSensors(sensor); 30 | } 31 | 32 | /** 33 | * 新增传感器信息 34 | * 35 | * @param sensor 36 | * @param field 37 | */ 38 | @Override 39 | public void addSensor(Sensor sensor, Field field) { 40 | this.convertNull(sensor, field); 41 | int res = sensorMapper.insertSensor(sensor); 42 | if (res <= 0) { 43 | throw new BusinessException("新增车辆信息失败,请检查新增编号是否存在!"); 44 | } 45 | } 46 | 47 | /** 48 | * 修改传感器信息 49 | * 50 | * @param sensor 51 | * @param field 52 | */ 53 | @Override 54 | public void modifySensor(Sensor sensor, Field field) { 55 | this.convertNull(sensor, field); 56 | int res = sensorMapper.updateSensor(sensor); 57 | if (res <= 0) { 58 | throw new BusinessException("修改传感器信息失败!"); 59 | } 60 | } 61 | 62 | /** 63 | * 删除传感器信息 64 | * 65 | * @param sensor 66 | */ 67 | @Override 68 | public void removeSensor(Sensor sensor) { 69 | int res = sensorMapper.deleteSensor(sensor); 70 | if (res <= 0) { 71 | throw new BusinessException("删除传感器信息失败!"); 72 | } 73 | } 74 | 75 | /** 76 | * 使得fieldId、sensorPs不为空字符串 77 | * 78 | * @param sensor sensorPs 79 | * @param field fieldId 80 | */ 81 | private void convertNull(Sensor sensor, Field field) { 82 | if ("".equals(sensor.getSensorPs())) { 83 | sensor.setSensorPs(null); 84 | } 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /src/test/java/com/njfu/ia/sys/service/SensorServiceTest.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.sys.service; 2 | 3 | import com.njfu.ia.sys.domain.Field; 4 | import com.njfu.ia.sys.domain.Sensor; 5 | import org.junit.Test; 6 | import org.junit.runner.RunWith; 7 | import org.slf4j.Logger; 8 | import org.slf4j.LoggerFactory; 9 | import org.springframework.boot.test.context.SpringBootTest; 10 | import org.springframework.test.context.junit4.SpringRunner; 11 | import org.springframework.transaction.annotation.Transactional; 12 | 13 | import javax.annotation.Resource; 14 | import java.util.List; 15 | 16 | @RunWith(SpringRunner.class) 17 | @SpringBootTest 18 | @Transactional 19 | public class SensorServiceTest { 20 | 21 | private static final Logger LOGGER = LoggerFactory.getLogger(SensorServiceTest.class); 22 | 23 | @Resource 24 | private SensorService sensorService; 25 | 26 | @Test 27 | public void getSensors() throws Exception { 28 | List sensors = sensorService.querySensors(new Sensor(), new Field()); 29 | 30 | LOGGER.info("sensors: {}", sensors); 31 | } 32 | 33 | @Test 34 | public void addSensor() throws Exception { 35 | Sensor sensor = new Sensor(); 36 | sensor.setSensorId("s-01-000"); 37 | sensor.setSensorFunc("1"); 38 | sensor.setSensorType("aaa001"); 39 | sensor.setUseStatus("0"); 40 | sensor.setSensorPs("test"); 41 | 42 | try { 43 | sensorService.addSensor(sensor, new Field()); 44 | } catch (Exception e) { 45 | e.printStackTrace(); 46 | } 47 | } 48 | 49 | @Test 50 | public void modifySensor() throws Exception { 51 | Sensor sensor = new Sensor(); 52 | sensor.setSensorId("s-01-001"); 53 | sensor.setSensorFunc("1"); 54 | sensor.setSensorType("aaa001"); 55 | sensor.setUseStatus("0"); 56 | sensor.setSensorPs("test"); 57 | 58 | try { 59 | sensorService.modifySensor(sensor, new Field()); 60 | } catch (Exception e) { 61 | e.printStackTrace(); 62 | } 63 | } 64 | 65 | @Test 66 | public void removeSensor() throws Exception { 67 | Sensor sensor = new Sensor(); 68 | sensor.setSensorId("s-01-001"); 69 | 70 | try { 71 | sensorService.removeSensor(sensor); 72 | } catch (Exception e) { 73 | e.printStackTrace(); 74 | } 75 | } 76 | 77 | } -------------------------------------------------------------------------------- /src/main/java/com/njfu/ia/sys/service/impl/AlarmRecordServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.sys.service.impl; 2 | 3 | import com.njfu.ia.sys.domain.AlarmRecord; 4 | import com.njfu.ia.sys.mapper.AlarmRecordMapper; 5 | import com.njfu.ia.sys.service.AlarmRecordService; 6 | import com.njfu.ia.sys.utils.Constants; 7 | import org.apache.shiro.SecurityUtils; 8 | import org.slf4j.Logger; 9 | import org.slf4j.LoggerFactory; 10 | import org.springframework.stereotype.Service; 11 | 12 | import javax.annotation.Resource; 13 | import java.util.List; 14 | 15 | @Service 16 | public class AlarmRecordServiceImpl implements AlarmRecordService { 17 | 18 | private static final Logger LOGGER = LoggerFactory.getLogger(AlarmRecordServiceImpl.class); 19 | 20 | @Resource 21 | private AlarmRecordMapper alarmRecordMapper; 22 | 23 | /** 24 | * 查询报警记录 25 | * 26 | * @param alarmRecord 27 | * @param start 28 | * @param end 29 | * @return 30 | */ 31 | @Override 32 | public List queryAlarmRecords(AlarmRecord alarmRecord, String start, String end) { 33 | return alarmRecordMapper.selectAlarmRecord(alarmRecord, start, end); 34 | } 35 | 36 | /** 37 | * 查询未处理报警记录 38 | * 39 | * @param alarmRecord 40 | * @return 41 | */ 42 | @Override 43 | public List queryUnhandleRecords() { 44 | AlarmRecord record = new AlarmRecord(); 45 | record.setHandleFlag(Constants.UNHANDLE_FLAG); 46 | return alarmRecordMapper.selectAlarmRecord(record, null, null); 47 | } 48 | 49 | /** 50 | * 查询未处理报警记录数量 51 | * 52 | * @return 53 | */ 54 | @Override 55 | public int queryUnhandleRecordsCount() { 56 | int count = 0; 57 | if (!Constants.USE_SHIRO || (Constants.USE_SHIRO && SecurityUtils.getSubject().isPermitted(Constants.WARN_PERM))) { 58 | List unhandleRecords = this.queryUnhandleRecords(); 59 | count = unhandleRecords.size(); 60 | } 61 | return count; 62 | } 63 | 64 | /** 65 | * 更新报警记录处理状态位 66 | * 67 | * @param ids 68 | * @param flag 69 | */ 70 | @Override 71 | public void modifyAlarmRecordFlag(Integer[] ids, Integer flag) { 72 | int count = alarmRecordMapper.updateAlarmRecordHandleFlag(ids, flag); 73 | if (count <= 0) { 74 | throw new RuntimeException("更新报警记录处理状态位失败!"); 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /src/main/java/com/njfu/ia/sys/service/impl/MachineServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.sys.service.impl; 2 | 3 | import com.njfu.ia.sys.domain.Block; 4 | import com.njfu.ia.sys.domain.Machine; 5 | import com.njfu.ia.sys.exception.BusinessException; 6 | import com.njfu.ia.sys.mapper.MachineMapper; 7 | import com.njfu.ia.sys.service.MachineService; 8 | import org.springframework.stereotype.Service; 9 | 10 | import javax.annotation.Resource; 11 | import java.util.List; 12 | 13 | @Service 14 | public class MachineServiceImpl implements MachineService { 15 | 16 | @Resource 17 | private MachineMapper machineMapper; 18 | 19 | /** 20 | * 获取机械列表 21 | * 22 | * @param machine 23 | * @param block 24 | * @return data 25 | */ 26 | @Override 27 | public List queryMachines(Machine machine, Block block) { 28 | machine.setBlock(block); 29 | return machineMapper.selectMachines(machine); 30 | } 31 | 32 | /** 33 | * 新增机械信息 34 | * 35 | * @param machine 36 | * @param block 37 | */ 38 | @Override 39 | public void addMachine(Machine machine, Block block) { 40 | this.convertNull(machine, block); 41 | int res = machineMapper.insertMachine(machine); 42 | if (res <= 0) { 43 | throw new BusinessException("新增机械信息失败,请检查新增编号是否存在!"); 44 | } 45 | } 46 | 47 | /** 48 | * 修改机械信息 49 | * 50 | * @param machine 51 | * @param block 52 | */ 53 | @Override 54 | public void modifyMachine(Machine machine, Block block) { 55 | this.convertNull(machine, block); 56 | int res = machineMapper.updateMachine(machine); 57 | if (res <= 0) { 58 | throw new BusinessException("修改机械信息失败!"); 59 | } 60 | } 61 | 62 | /** 63 | * 删除机械信息 64 | * 65 | * @param machine 66 | */ 67 | @Override 68 | public void removeMachine(Machine machine) { 69 | int res = machineMapper.deleteMachine(machine); 70 | if (res <= 0) { 71 | throw new BusinessException("删除机械信息失败!"); 72 | } 73 | } 74 | 75 | /** 76 | * 若machinePs、blockId为空字符串,转为null 77 | * 78 | * @param machine 79 | * @param block 80 | */ 81 | private void convertNull(Machine machine, Block block) { 82 | if ("".equals(machine.getMachinePs())) { 83 | machine.setMachinePs(null); 84 | } 85 | 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /src/test/java/com/njfu/ia/sys/service/MachineServiceTest.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.sys.service; 2 | 3 | import com.njfu.ia.sys.domain.Block; 4 | import com.njfu.ia.sys.domain.Machine; 5 | import org.junit.Test; 6 | import org.junit.runner.RunWith; 7 | import org.slf4j.Logger; 8 | import org.slf4j.LoggerFactory; 9 | import org.springframework.boot.test.context.SpringBootTest; 10 | import org.springframework.test.context.junit4.SpringRunner; 11 | import org.springframework.transaction.annotation.Transactional; 12 | 13 | import javax.annotation.Resource; 14 | import java.util.List; 15 | 16 | @RunWith(SpringRunner.class) 17 | @SpringBootTest 18 | @Transactional 19 | public class MachineServiceTest { 20 | 21 | private static final Logger LOGGER = LoggerFactory.getLogger(MachineServiceTest.class); 22 | 23 | @Resource 24 | private MachineService machineService; 25 | 26 | @Test 27 | public void getMachines() throws Exception { 28 | List machines = machineService.queryMachines(new Machine(), new Block()); 29 | LOGGER.info("machines: {}", machines); 30 | } 31 | 32 | @Test 33 | public void addMachine() throws Exception { 34 | Machine machine = new Machine(); 35 | machine.setMachineId("m000"); 36 | machine.setMachineType("xyz"); 37 | Block block = new Block(); 38 | machine.setUseStatus("0"); 39 | machine.setMachinePs("test"); 40 | 41 | try { 42 | machineService.addMachine(machine, block); 43 | } catch (Exception e) { 44 | e.printStackTrace(); 45 | } 46 | } 47 | 48 | @Test 49 | public void modifyMachine() throws Exception { 50 | Machine machine = new Machine(); 51 | machine.setMachineId("m001"); 52 | machine.setMachineType("xyz"); 53 | 54 | Block block = new Block(); 55 | 56 | machine.setUseStatus("0"); 57 | machine.setMachinePs("test"); 58 | 59 | try { 60 | machineService.modifyMachine(machine, block); 61 | } catch (Exception e) { 62 | e.printStackTrace(); 63 | } 64 | } 65 | 66 | @Test 67 | public void removeMachine() throws Exception { 68 | Machine machine = new Machine(); 69 | machine.setMachineId("m001"); 70 | 71 | try { 72 | machineService.removeMachine(machine); 73 | } catch (Exception e) { 74 | e.printStackTrace(); 75 | } 76 | } 77 | 78 | } -------------------------------------------------------------------------------- /src/main/java/com/njfu/ia/sys/utils/Result.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.sys.utils; 2 | 3 | import com.njfu.ia.sys.enums.ResultEnum; 4 | 5 | /** 6 | * 统一返回结果 7 | */ 8 | public class Result { 9 | 10 | /** 11 | * 成功与否 12 | */ 13 | private boolean success; 14 | 15 | /** 16 | * 消息代码 17 | */ 18 | private Integer code; 19 | 20 | /** 21 | * 消息描述信息 22 | */ 23 | private String message; 24 | 25 | /** 26 | * 消息具体内容 27 | */ 28 | private T data; 29 | 30 | public Result(Integer code, String message, T data) { 31 | if (code >= ResultEnum.FAIL.code()) { 32 | this.success = Boolean.FALSE; 33 | } else { 34 | this.success = Boolean.TRUE; 35 | } 36 | this.code = code; 37 | this.message = message; 38 | this.data = data; 39 | } 40 | 41 | /** 42 | * 响应结果 43 | * 44 | * @param resultEnum resultEnum 结果代码 45 | * @param message message 46 | * @param data data 47 | * @param T 48 | * @return response 49 | */ 50 | public static Result response(ResultEnum resultEnum, String message, T data) { 51 | return new Result<>(resultEnum.code(), message, data); 52 | } 53 | 54 | /** 55 | * 响应结果 56 | * 57 | * @param resultEnum resultEnum 结果代码 58 | * @param data data 59 | * @param T 60 | * @return response 61 | */ 62 | public static Result response(ResultEnum resultEnum, T data) { 63 | return new Result<>(resultEnum.code(), null, data); 64 | } 65 | 66 | /** 67 | * 响应结果 68 | * 69 | * @param resultEnum resultEnum 结果代码 70 | * @param T 71 | * @return response 72 | */ 73 | public static Result response(ResultEnum resultEnum) { 74 | return response(resultEnum, null); 75 | } 76 | 77 | public boolean isSuccess() { 78 | return success; 79 | } 80 | 81 | public void setSuccess(boolean success) { 82 | this.success = success; 83 | } 84 | 85 | public Integer getCode() { 86 | return code; 87 | } 88 | 89 | public void setCode(Integer code) { 90 | this.code = code; 91 | } 92 | 93 | public String getMessage() { 94 | return message; 95 | } 96 | 97 | public void setMessage(String message) { 98 | this.message = message; 99 | } 100 | 101 | public T getData() { 102 | return data; 103 | } 104 | 105 | public void setData(T data) { 106 | this.data = data; 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /IA-PCS/src/main/java/com/njfu/ia/process/domain/AlarmRecord.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.process.domain; 2 | 3 | import com.fasterxml.jackson.annotation.JsonFormat; 4 | 5 | import java.util.Date; 6 | 7 | /** 8 | * 报警记录 9 | */ 10 | public class AlarmRecord { 11 | 12 | /** 13 | * 记录编号 14 | */ 15 | private Integer id; 16 | 17 | /** 18 | * 来源终端设备编号 19 | */ 20 | private Integer deviceId; 21 | 22 | /** 23 | * 数据类型 24 | */ 25 | private Integer dataType; 26 | 27 | /** 28 | * 数据值 29 | */ 30 | private Double value; 31 | 32 | /** 33 | * 报警时间 34 | */ 35 | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") 36 | private Date alarmTime; 37 | 38 | /** 39 | * 处理时间 40 | */ 41 | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") 42 | private Date handleTime; 43 | 44 | /** 45 | * 处理标志 0-未处理 1-已处理 2-已忽略 46 | */ 47 | private Integer handleFlag; 48 | 49 | public AlarmRecord() { 50 | } 51 | 52 | public AlarmRecord(UpstreamDataRecord record) { 53 | this.deviceId = record.getDeviceId(); 54 | this.dataType = record.getDataType(); 55 | this.value = record.getValue(); 56 | this.alarmTime = record.getReceiveTime(); 57 | } 58 | 59 | public Integer getId() { 60 | return id; 61 | } 62 | 63 | public void setId(Integer id) { 64 | this.id = id; 65 | } 66 | 67 | public Integer getDeviceId() { 68 | return deviceId; 69 | } 70 | 71 | public void setDeviceId(Integer deviceId) { 72 | this.deviceId = deviceId; 73 | } 74 | 75 | public Integer getDataType() { 76 | return dataType; 77 | } 78 | 79 | public void setDataType(Integer dataType) { 80 | this.dataType = dataType; 81 | } 82 | 83 | public Double getValue() { 84 | return value; 85 | } 86 | 87 | public void setValue(Double value) { 88 | this.value = value; 89 | } 90 | 91 | public Date getAlarmTime() { 92 | return alarmTime; 93 | } 94 | 95 | public void setAlarmTime(Date alarmTime) { 96 | this.alarmTime = alarmTime; 97 | } 98 | 99 | public Date getHandleTime() { 100 | return handleTime; 101 | } 102 | 103 | public void setHandleTime(Date handleTime) { 104 | this.handleTime = handleTime; 105 | } 106 | 107 | public Integer getHandleFlag() { 108 | return handleFlag; 109 | } 110 | 111 | public void setHandleFlag(Integer handleFlag) { 112 | this.handleFlag = handleFlag; 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /IA-PCS/src/main/java/com/njfu/ia/process/jms/consumer/handler/OnUpstreamHandler.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.process.jms.consumer.handler; 2 | 3 | import com.njfu.ia.process.domain.DownstreamRet; 4 | import com.njfu.ia.process.domain.EndDevice; 5 | import com.njfu.ia.process.domain.InformRet; 6 | import com.njfu.ia.process.jms.JmsSender; 7 | import com.njfu.ia.process.mapper.EndDeviceMapper; 8 | import com.njfu.ia.process.utils.Constants; 9 | import com.njfu.ia.process.utils.JsonUtils; 10 | import org.slf4j.Logger; 11 | import org.slf4j.LoggerFactory; 12 | 13 | import javax.annotation.Resource; 14 | import java.util.Date; 15 | import java.util.Map; 16 | 17 | /** 18 | * 上线上行数据处理器 19 | */ 20 | public class OnUpstreamHandler extends UpstreamHandler { 21 | 22 | private static final Logger LOGGER = LoggerFactory.getLogger(OnUpstreamHandler.class); 23 | 24 | @Resource 25 | private EndDeviceMapper endDeviceMapper; 26 | 27 | @Resource 28 | private JmsSender jmsSender; 29 | 30 | public OnUpstreamHandler(Date receiveTime, Map retMap) { 31 | super(receiveTime, retMap); 32 | } 33 | 34 | /** 35 | * 上线消息处理 tp:0|mac:00-12-4B-00-03-98-A1-AB 36 | * 1.更新上线状态 37 | * 2.分配设备编号 tp:0|mac:00-12-4B-00-03-98-A1-AB|id:1 38 | * 3.推送上线消息 39 | */ 40 | @Override 41 | public void handleUpstream() { 42 | Map retMap = super.getRetMap(); 43 | // 获取mac地址 44 | String mac = (String) retMap.get(Constants.RET_MAC); 45 | EndDevice device = endDeviceMapper.selectDeviceByMac(mac); 46 | if (null == device) { 47 | return; 48 | } 49 | // 获取设备编号 50 | Integer deviceId = device.getId(); 51 | Integer useStatus = device.getUseStatus(); 52 | if (useStatus != Constants.UNUSE) { 53 | // 终端未处于不使用 54 | device.setUseStatus(Constants.INUSE); 55 | // 更新终端信息 56 | endDeviceMapper.updateDevice(device); 57 | 58 | // 分配设备编号 59 | DownstreamRet downstreamRet = new DownstreamRet(); 60 | downstreamRet.setMsgType(Constants.MESSAGE_DOWNSTREAM_ON); 61 | downstreamRet.setMac(mac); 62 | downstreamRet.setDeviceId(deviceId); 63 | // 分配终端设备编号 64 | jmsSender.sendMessage(Constants.MESSAGE_DOWNSTREAM_ON, JsonUtils.toJsonString(downstreamRet)); 65 | 66 | InformRet informRet = new InformRet(); 67 | informRet.setMsgType(Constants.MESSAGE_INFORM_ON); 68 | informRet.setDeviceId(deviceId); 69 | // 推送上线消息 70 | jmsSender.sendMessage(Constants.MESSAGE_INFORM_ON, JsonUtils.toJsonString(informRet)); 71 | LOGGER.info("end device {} on", deviceId); 72 | } 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /src/main/resources/templates/sys/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | <#include "/common/standard.html"/> 6 | 首页-欢迎使用智慧农业管理系统 7 | 8 | 9 |
10 | 11 | <#include "/common/topNav.html"/> 12 | 13 | 14 | <#include "/sys/sysSideNav.html"/> 15 | 16 | 17 |
18 |
19 |
20 | 25 |
26 | 27 | 59 |
60 |
61 | 62 |
63 | 64 | 65 | -------------------------------------------------------------------------------- /src/main/java/com/njfu/ia/sys/web/SecurityController.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.sys.web; 2 | 3 | 4 | import com.njfu.ia.sys.enums.ResultEnum; 5 | import com.njfu.ia.sys.utils.Result; 6 | import org.apache.shiro.SecurityUtils; 7 | import org.apache.shiro.authc.AccountException; 8 | import org.apache.shiro.authc.IncorrectCredentialsException; 9 | import org.apache.shiro.authc.UsernamePasswordToken; 10 | import org.apache.shiro.subject.Subject; 11 | import org.slf4j.Logger; 12 | import org.slf4j.LoggerFactory; 13 | import org.springframework.stereotype.Controller; 14 | import org.springframework.ui.Model; 15 | import org.springframework.web.bind.annotation.GetMapping; 16 | import org.springframework.web.bind.annotation.PostMapping; 17 | import org.springframework.web.bind.annotation.RequestMapping; 18 | import org.springframework.web.bind.annotation.ResponseBody; 19 | 20 | import javax.servlet.http.HttpServletRequest; 21 | 22 | @Controller 23 | public class SecurityController { 24 | 25 | private static final Logger LOGGER = LoggerFactory.getLogger(SecurityController.class); 26 | 27 | /** 28 | * 登录页面 29 | * 30 | * @return Page 31 | */ 32 | @RequestMapping("") 33 | public String loginPage() { 34 | if (SecurityUtils.getSubject().isAuthenticated()) { 35 | // 若已通过认证,转到首页 36 | return "redirect:/sys"; 37 | } 38 | return "login"; 39 | } 40 | 41 | /** 42 | * 验证登录 43 | * 44 | * @return json data 45 | */ 46 | @PostMapping(value = "/login") 47 | public @ResponseBody 48 | Result login(String username, String password, HttpServletRequest request) { 49 | try { 50 | UsernamePasswordToken token = new UsernamePasswordToken(username, password); 51 | // 登录失败:包括账户不存在、密码错误等,都会抛出ShiroException 52 | Subject subject = SecurityUtils.getSubject(); 53 | subject.login(token); 54 | LOGGER.info("{} login, from {}", subject.getPrincipal(), request.getRemoteAddr()); 55 | return Result.response(ResultEnum.SUCCESS); 56 | } catch (AccountException e) { 57 | return Result.response(ResultEnum.FAIL, e.getMessage(), null); 58 | } catch (IncorrectCredentialsException e) { 59 | return Result.response(ResultEnum.FAIL, "密码错误!", null); 60 | } catch (Exception e) { 61 | LOGGER.error(e.getMessage(), e); 62 | return Result.response(ResultEnum.FAIL); 63 | } 64 | } 65 | 66 | /** 67 | * 未授权跳转 68 | * 69 | * @param model 403 status 70 | * @return errorPage 71 | */ 72 | @GetMapping("/403") 73 | public String forbidden(Model model) { 74 | model.addAttribute("status", "403"); 75 | return "error"; 76 | } 77 | } -------------------------------------------------------------------------------- /IA-PCS/src/main/java/com/njfu/ia/process/domain/EndDevice.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.process.domain; 2 | 3 | import com.fasterxml.jackson.annotation.JsonFormat; 4 | 5 | import java.util.Date; 6 | 7 | /** 8 | * 设备终端 9 | */ 10 | public class EndDevice { 11 | 12 | /** 13 | * 终端编号 14 | */ 15 | private Integer id; 16 | 17 | /** 18 | * 终端型号 19 | */ 20 | private String model; 21 | 22 | /** 23 | * 终端mac地址 24 | */ 25 | private String mac; 26 | 27 | /** 28 | * 所属区块编号 29 | */ 30 | private Integer sectionId; 31 | 32 | /** 33 | * 终端使用状态:0,未使用;1,使用中;2:故障中 34 | */ 35 | private Integer useStatus; 36 | 37 | /** 38 | * 创建时间 39 | */ 40 | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") 41 | private Date createTime; 42 | 43 | /** 44 | * 更新时间 45 | */ 46 | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") 47 | private Date updateTime; 48 | 49 | public EndDevice() { 50 | } 51 | 52 | public Integer getId() { 53 | return id; 54 | } 55 | 56 | public void setId(Integer id) { 57 | this.id = id; 58 | } 59 | 60 | public String getModel() { 61 | return model; 62 | } 63 | 64 | public void setModel(String model) { 65 | this.model = model; 66 | } 67 | 68 | public String getMac() { 69 | return mac; 70 | } 71 | 72 | public void setMac(String mac) { 73 | this.mac = mac; 74 | } 75 | 76 | public Integer getSectionId() { 77 | return sectionId; 78 | } 79 | 80 | public void setSectionId(Integer sectionId) { 81 | this.sectionId = sectionId; 82 | } 83 | 84 | public Integer getUseStatus() { 85 | return useStatus; 86 | } 87 | 88 | public void setUseStatus(Integer useStatus) { 89 | this.useStatus = useStatus; 90 | } 91 | 92 | public Date getCreateTime() { 93 | return createTime; 94 | } 95 | 96 | public void setCreateTime(Date createTime) { 97 | this.createTime = createTime; 98 | } 99 | 100 | public Date getUpdateTime() { 101 | return updateTime; 102 | } 103 | 104 | public void setUpdateTime(Date updateTime) { 105 | this.updateTime = updateTime; 106 | } 107 | 108 | @Override 109 | public String toString() { 110 | return "EndDevice{" + 111 | "id=" + id + 112 | ", model='" + model + '\'' + 113 | ", mac='" + mac + '\'' + 114 | ", sectionId=" + sectionId + 115 | ", useStatus=" + useStatus + 116 | ", createTime=" + createTime + 117 | ", updateTime=" + updateTime + 118 | '}'; 119 | } 120 | } 121 | -------------------------------------------------------------------------------- /src/main/java/com/njfu/ia/sys/domain/EndDevice.java: -------------------------------------------------------------------------------- 1 | package com.njfu.ia.sys.domain; 2 | 3 | import com.fasterxml.jackson.annotation.JsonFormat; 4 | import com.njfu.ia.sys.utils.Constants; 5 | 6 | import java.util.Date; 7 | 8 | /** 9 | * 设备终端 10 | */ 11 | public class EndDevice { 12 | 13 | /** 14 | * 终端编号 15 | */ 16 | private Integer id; 17 | 18 | /** 19 | * 终端型号 20 | */ 21 | private String model; 22 | 23 | /** 24 | * 终端类型:0-终端,1-路由器,2-协调器 25 | */ 26 | private Integer type; 27 | 28 | /** 29 | * 终端mac地址 30 | */ 31 | private String mac; 32 | 33 | /** 34 | * 所属区块编号 35 | */ 36 | private Integer sectionId; 37 | 38 | /** 39 | * 终端使用状态:0,未使用;1,使用中;2:故障中 40 | */ 41 | private Integer useStatus; 42 | 43 | /** 44 | * 创建时间 45 | */ 46 | @JsonFormat(pattern = Constants.DATE_SECOND_FORMAT, timezone = Constants.DEFAULT_GMT) 47 | private Date createTime; 48 | 49 | /** 50 | * 更新时间 51 | */ 52 | @JsonFormat(pattern = Constants.DATE_SECOND_FORMAT, timezone = Constants.DEFAULT_GMT) 53 | private Date updateTime; 54 | 55 | public EndDevice() { 56 | } 57 | 58 | public Integer getId() { 59 | return id; 60 | } 61 | 62 | public void setId(Integer id) { 63 | this.id = id; 64 | } 65 | 66 | public String getModel() { 67 | return model; 68 | } 69 | 70 | public void setModel(String model) { 71 | this.model = model; 72 | } 73 | 74 | public Integer getType() { 75 | return type; 76 | } 77 | 78 | public void setType(Integer type) { 79 | this.type = type; 80 | } 81 | 82 | public String getMac() { 83 | return mac; 84 | } 85 | 86 | public void setMac(String mac) { 87 | this.mac = mac; 88 | } 89 | 90 | public Integer getSectionId() { 91 | return sectionId; 92 | } 93 | 94 | public void setSectionId(Integer sectionId) { 95 | this.sectionId = sectionId; 96 | } 97 | 98 | public Integer getUseStatus() { 99 | return useStatus; 100 | } 101 | 102 | public void setUseStatus(Integer useStatus) { 103 | this.useStatus = useStatus; 104 | } 105 | 106 | public Date getCreateTime() { 107 | return createTime; 108 | } 109 | 110 | public void setCreateTime(Date createTime) { 111 | this.createTime = createTime; 112 | } 113 | 114 | public Date getUpdateTime() { 115 | return updateTime; 116 | } 117 | 118 | public void setUpdateTime(Date updateTime) { 119 | this.updateTime = updateTime; 120 | } 121 | } 122 | --------------------------------------------------------------------------------