Commit d9f8d9371d15cc190a109d4c1d8493010b21293f
1 parent
214a3706
feat: 新增获取设备号
Showing
5 changed files
with
54 additions
and
48 deletions
Bsth-admin/src/main/java/com/ruoyi/BsthServletInitializer.java
| ... | ... | @@ -2,14 +2,6 @@ package com.ruoyi; |
| 2 | 2 | |
| 3 | 3 | import org.springframework.boot.builder.SpringApplicationBuilder; |
| 4 | 4 | import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; |
| 5 | -import org.springframework.http.HttpEntity; | |
| 6 | -import org.springframework.http.HttpHeaders; | |
| 7 | -import org.springframework.http.HttpMethod; | |
| 8 | -import org.springframework.http.ResponseEntity; | |
| 9 | -import org.springframework.web.client.RestTemplate; | |
| 10 | - | |
| 11 | -import java.util.HashMap; | |
| 12 | -import java.util.Map; | |
| 13 | 5 | |
| 14 | 6 | /** |
| 15 | 7 | * web容器中进行部署 |
| ... | ... | @@ -23,22 +15,4 @@ public class BsthServletInitializer extends SpringBootServletInitializer |
| 23 | 15 | { |
| 24 | 16 | return application.sources(BsthApplication.class); |
| 25 | 17 | } |
| 26 | - | |
| 27 | - // 测试方法 | |
| 28 | - public static void main(String[] args) { | |
| 29 | - RestTemplate restTemplate = new RestTemplate(); | |
| 30 | - String url = "http://1.14.107.94:8100/driver/driver"; | |
| 31 | - HttpHeaders headers = new HttpHeaders(); | |
| 32 | - headers.set("Authorization", "Bearer eyJhbGciOiJIUzUxMiJ9.eyJsb2dpbl91c2VyX2tleSI6ImNhOGRhOGJlLWQ0ZjItNDhjMy05ZWU1LWJkMDQzYzY3YzQ0MyJ9.79b8JM31faxhLnIqu6xGtrx1JK019NoN26AwNfPzptYSriHSTABdYp16kzKD538wo2HfXhYoviSqy4qZfoEV5Q"); | |
| 33 | - Map<String, String> requestBody = new HashMap<>(); | |
| 34 | - requestBody.put("jobCode", "asdfasd"); | |
| 35 | - requestBody.put("personnelName", "asdfasdf"); | |
| 36 | - | |
| 37 | - HttpEntity<Map<String, String>> entity = new HttpEntity<>(requestBody, headers); | |
| 38 | - | |
| 39 | - ResponseEntity<String> response = restTemplate.exchange(url, HttpMethod.POST, entity, String.class); | |
| 40 | - | |
| 41 | - String responseBody = response.getBody(); | |
| 42 | - System.out.println(responseBody); | |
| 43 | - } | |
| 44 | 18 | } | ... | ... |
Bsth-admin/src/main/java/com/ruoyi/equipment/controller/EquipmentController.java
| ... | ... | @@ -100,6 +100,15 @@ public class EquipmentController extends BaseController { |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | /** |
| 103 | + * 查询当前所有设备信息 | |
| 104 | + */ | |
| 105 | + @GetMapping("/getEquipmentAll") | |
| 106 | + @ApiOperation("获取所有设备设备号") | |
| 107 | + public AjaxResult getEquipmentAll(){ | |
| 108 | + return AjaxResult.success(equipmentService.getEquipmentAll()); | |
| 109 | + } | |
| 110 | + | |
| 111 | + /** | |
| 103 | 112 | * 删除设备信息 |
| 104 | 113 | */ |
| 105 | 114 | // @PreAuthorize("@ss.hasPermi('equipment:equipment:remove')") | ... | ... |
Bsth-admin/src/main/java/com/ruoyi/equipment/service/IEquipmentService.java
| ... | ... | @@ -3,6 +3,7 @@ package com.ruoyi.equipment.service; |
| 3 | 3 | import java.util.List; |
| 4 | 4 | import com.ruoyi.equipment.domain.Equipment; |
| 5 | 5 | import com.ruoyi.equipment.domain.EquipmentLog; |
| 6 | +import com.ruoyi.pojo.vo.EquipmentResponseVo; | |
| 6 | 7 | |
| 7 | 8 | /** |
| 8 | 9 | * 设备信息Service接口 |
| ... | ... | @@ -61,4 +62,6 @@ public interface IEquipmentService |
| 61 | 62 | public int deleteEquipmentById(Long id); |
| 62 | 63 | |
| 63 | 64 | List<EquipmentLog> queryLog(EquipmentLog log); |
| 65 | + | |
| 66 | + List<EquipmentResponseVo> getEquipmentAll(); | |
| 64 | 67 | } | ... | ... |
Bsth-admin/src/main/java/com/ruoyi/equipment/service/impl/EquipmentServiceImpl.java
| 1 | 1 | package com.ruoyi.equipment.service.impl; |
| 2 | 2 | |
| 3 | 3 | import java.util.List; |
| 4 | +import java.util.stream.Collectors; | |
| 5 | + | |
| 4 | 6 | import com.ruoyi.common.utils.DateUtils; |
| 5 | 7 | import com.ruoyi.common.utils.SecurityUtils; |
| 6 | 8 | import com.ruoyi.common.utils.StringUtils; |
| 7 | 9 | import com.ruoyi.equipment.domain.EquipmentLog; |
| 8 | 10 | import com.ruoyi.pojo.equipment.EquipmentOnline; |
| 11 | +import com.ruoyi.pojo.vo.EquipmentResponseVo; | |
| 9 | 12 | import org.springframework.beans.factory.annotation.Autowired; |
| 10 | 13 | import org.springframework.stereotype.Service; |
| 11 | 14 | import com.ruoyi.equipment.mapper.EquipmentMapper; |
| ... | ... | @@ -16,13 +19,12 @@ import javax.annotation.Resource; |
| 16 | 19 | |
| 17 | 20 | /** |
| 18 | 21 | * 设备信息Service业务层处理 |
| 19 | - * | |
| 22 | + * | |
| 20 | 23 | * @author guzijian |
| 21 | 24 | * @date 2023-07-05 |
| 22 | 25 | */ |
| 23 | 26 | @Service |
| 24 | -public class EquipmentServiceImpl implements IEquipmentService | |
| 25 | -{ | |
| 27 | +public class EquipmentServiceImpl implements IEquipmentService { | |
| 26 | 28 | @Autowired |
| 27 | 29 | private EquipmentMapper equipmentMapper; |
| 28 | 30 | |
| ... | ... | @@ -31,40 +33,37 @@ public class EquipmentServiceImpl implements IEquipmentService |
| 31 | 33 | |
| 32 | 34 | /** |
| 33 | 35 | * 查询设备信息 |
| 34 | - * | |
| 36 | + * | |
| 35 | 37 | * @param id 设备信息主键 |
| 36 | 38 | * @return 设备信息 |
| 37 | 39 | */ |
| 38 | 40 | @Override |
| 39 | - public Equipment selectEquipmentById(Long id) | |
| 40 | - { | |
| 41 | + public Equipment selectEquipmentById(Long id) { | |
| 41 | 42 | return equipmentMapper.selectEquipmentById(id); |
| 42 | 43 | } |
| 43 | 44 | |
| 44 | 45 | /** |
| 45 | 46 | * 查询设备信息列表 |
| 46 | - * | |
| 47 | + * | |
| 47 | 48 | * @param equipment 设备信息 |
| 48 | 49 | * @return 设备信息 |
| 49 | 50 | */ |
| 50 | 51 | @Override |
| 51 | - public List<Equipment> selectEquipmentList(Equipment equipment) | |
| 52 | - { | |
| 52 | + public List<Equipment> selectEquipmentList(Equipment equipment) { | |
| 53 | 53 | return equipmentMapper.selectEquipmentList(equipment); |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | /** |
| 57 | 57 | * 新增设备信息 |
| 58 | - * | |
| 58 | + * | |
| 59 | 59 | * @param equipment 设备信息 |
| 60 | 60 | * @return 结果 |
| 61 | 61 | */ |
| 62 | 62 | @Override |
| 63 | - public int insertEquipment(Equipment equipment) | |
| 64 | - { | |
| 63 | + public int insertEquipment(Equipment equipment) { | |
| 65 | 64 | equipment.setCreateTime(DateUtils.getNowDate()); |
| 66 | 65 | equipment.setCreateBy(SecurityUtils.getUsername()); |
| 67 | - if (!StringUtils.isNotEmpty(equipment.getDeviceId())){ | |
| 66 | + if (!StringUtils.isNotEmpty(equipment.getDeviceId())) { | |
| 68 | 67 | throw new RuntimeException("设备号不能为空"); |
| 69 | 68 | } |
| 70 | 69 | return equipmentMapper.insertEquipment(equipment); |
| ... | ... | @@ -72,13 +71,12 @@ public class EquipmentServiceImpl implements IEquipmentService |
| 72 | 71 | |
| 73 | 72 | /** |
| 74 | 73 | * 修改设备信息 |
| 75 | - * | |
| 74 | + * | |
| 76 | 75 | * @param equipment 设备信息 |
| 77 | 76 | * @return 结果 |
| 78 | 77 | */ |
| 79 | 78 | @Override |
| 80 | - public int updateEquipment(Equipment equipment) | |
| 81 | - { | |
| 79 | + public int updateEquipment(Equipment equipment) { | |
| 82 | 80 | equipment.setUpdateTime(DateUtils.getNowDate()); |
| 83 | 81 | equipment.setUpdateBy(SecurityUtils.getUsername()); |
| 84 | 82 | return equipmentMapper.updateEquipment(equipment); |
| ... | ... | @@ -86,25 +84,23 @@ public class EquipmentServiceImpl implements IEquipmentService |
| 86 | 84 | |
| 87 | 85 | /** |
| 88 | 86 | * 批量删除设备信息 |
| 89 | - * | |
| 87 | + * | |
| 90 | 88 | * @param ids 需要删除的设备信息主键 |
| 91 | 89 | * @return 结果 |
| 92 | 90 | */ |
| 93 | 91 | @Override |
| 94 | - public int deleteEquipmentByIds(Long[] ids) | |
| 95 | - { | |
| 92 | + public int deleteEquipmentByIds(Long[] ids) { | |
| 96 | 93 | return equipmentMapper.deleteEquipmentByIds(ids); |
| 97 | 94 | } |
| 98 | 95 | |
| 99 | 96 | /** |
| 100 | 97 | * 删除设备信息信息 |
| 101 | - * | |
| 98 | + * | |
| 102 | 99 | * @param id 设备信息主键 |
| 103 | 100 | * @return 结果 |
| 104 | 101 | */ |
| 105 | 102 | @Override |
| 106 | - public int deleteEquipmentById(Long id) | |
| 107 | - { | |
| 103 | + public int deleteEquipmentById(Long id) { | |
| 108 | 104 | return equipmentMapper.deleteEquipmentById(id); |
| 109 | 105 | } |
| 110 | 106 | |
| ... | ... | @@ -112,4 +108,16 @@ public class EquipmentServiceImpl implements IEquipmentService |
| 112 | 108 | public List<EquipmentLog> queryLog(EquipmentLog log) { |
| 113 | 109 | return equipmentMapper.queryLog(log); |
| 114 | 110 | } |
| 111 | + | |
| 112 | + @Override | |
| 113 | + public List<EquipmentResponseVo> getEquipmentAll() { | |
| 114 | + List<Equipment> list = equipmentMapper.selectEquipmentList(null); | |
| 115 | + | |
| 116 | + return list.stream().map(item -> { | |
| 117 | + EquipmentResponseVo vo = new EquipmentResponseVo(); | |
| 118 | + vo.setLabel(item.getDeviceId()); | |
| 119 | + vo.setValue(item.getDeviceId()); | |
| 120 | + return vo; | |
| 121 | + }).collect(Collectors.toList()); | |
| 122 | + } | |
| 115 | 123 | } | ... | ... |
Bsth-admin/src/main/java/com/ruoyi/pojo/vo/EquipmentResponseVo.java
0 → 100644