10 |
11 | <#include "/common/topNav.html"/>
12 |
13 |
14 | <#include "/sys/sysSideNav.html"/>
15 |
16 |
17 |
18 |
19 |
22 |
23 |
24 |
25 | - 首页
26 | - 记录管理
27 |
28 |
29 |
30 |
31 |
32 | -
33 | 日志
34 |
35 | -
36 | 备忘录
37 |
38 | -
39 | 注意事项
40 |
41 |
42 |
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 |
--------------------------------------------------------------------------------