Kaynağa Gözat

优化data-transfer服务模块中指令记录列表接口,在DmpDeviceCommand类文件新增上面两个字段,并在查询条件中增加操作人字段刷选,同时修改下发命令控制接口字段逻辑

james 4 ay önce
ebeveyn
işleme
274eeab731

+ 1 - 1
data-transfer/data-transfer-api/src/main/java/com/usky/transfer/RemoteTransferService.java

@@ -24,5 +24,5 @@ public interface RemoteTransferService {
      * 下发单个设备控制命令
      */
     @PostMapping("/deviceControl")
-    Map<String,Object> deviceControl(@RequestParam("productCode") String productCode, @RequestParam(value = "deviceId",required = false) String deviceId, @RequestParam("commandStr") String commandStr,@RequestParam(value = "tenantId") Integer tenantId);
+    Map<String,Object> deviceControl(@RequestParam("productCode") String productCode, @RequestParam(value = "deviceId",required = false) String deviceId, @RequestParam("commandStr") String commandStr,@RequestParam(value = "tenantId") Integer tenantId, @RequestParam(value = "userId") Long userId, @RequestParam(value = "userName") String userName);
 }

+ 1 - 1
data-transfer/data-transfer-api/src/main/java/com/usky/transfer/factory/RemoteTransferFallbackFactory.java

@@ -36,7 +36,7 @@ public class RemoteTransferFallbackFactory implements FallbackFactory<RemoteTran
                 throw new BusinessException(throwable.getMessage());
             }
             @Override
-            public Map<String,Object> deviceControl(String productCode, String deviceId, String commandStr,Integer tenantId) {
+            public Map<String,Object> deviceControl(String productCode, String deviceId, String commandStr,Integer tenantId, Long userId, String userName) {
                 throw new BusinessException(throwable.getMessage());
             }
         };

+ 2 - 2
data-transfer/data-transfer-biz/src/main/java/com/usky/transfer/controller/api/DataTransferControllerApi.java

@@ -29,7 +29,7 @@ public class DataTransferControllerApi implements RemoteTransferService {
      * 下发单个设备控制命令
      */
     @Override
-    public Map<String,Object> deviceControl(String productCode, String deviceId, String commandStr,Integer tenantId){
-        return queryInfluxdbDataService.deviceControl(productCode, deviceId, commandStr, tenantId);
+    public Map<String,Object> deviceControl(String productCode, String deviceId, String commandStr,Integer tenantId, Long userId, String userName){
+        return queryInfluxdbDataService.deviceControl(productCode, deviceId, commandStr, tenantId, userId, userName);
     }
 }

+ 5 - 1
data-transfer/data-transfer-biz/src/main/java/com/usky/transfer/controller/web/QueryDeviceDataController.java

@@ -189,6 +189,9 @@ public class QueryDeviceDataController {
     /**
      * 指令记录
      * @param commandStatus
+     * @param productCode
+     * @param deviceId
+     * @param userName
      * @param startTime
      * @param endTime
      * @param pageNum
@@ -199,10 +202,11 @@ public class QueryDeviceDataController {
     public ApiResult<CommonPage<DmpDeviceCommand>> deviceCommandRecord(@RequestParam(value = "commandStatus",required = false) Integer commandStatus,
                                                                        @RequestParam(value = "productCode",required = false) String productCode,
                                                                        @RequestParam(value = "deviceId",required = false) String deviceId,
+                                                                       @RequestParam(value = "userName",required = false) String userName,
                                                                        @RequestParam(value = "startTime",required = false) String startTime,
                                                                        @RequestParam(value = "endTime",required = false) String endTime,
                                                                        @RequestParam(value = "pageNum", required = false, defaultValue = "1") Integer pageNum,
                                                                        @RequestParam(value = "pageSize", required = false, defaultValue = "10") Integer pageSize){
-        return ApiResult.success(dmpDeviceCommandService.deviceCommandRecord(commandStatus,productCode,deviceId,startTime,endTime,pageNum,pageSize));
+        return ApiResult.success(dmpDeviceCommandService.deviceCommandRecord(commandStatus,productCode,deviceId,userName,startTime,endTime,pageNum,pageSize));
     }
 }

+ 10 - 0
data-transfer/data-transfer-biz/src/main/java/com/usky/transfer/domain/DmpDeviceCommand.java

@@ -82,5 +82,15 @@ public class DmpDeviceCommand implements Serializable {
      */
     private Integer tenantId;
 
+    /**
+     * 操作人
+     */
+    private String userName;
+
+    /**
+     * 操作人Id
+     */
+    private Long userId;
+
 
 }

+ 1 - 1
data-transfer/data-transfer-biz/src/main/java/com/usky/transfer/service/DmpDeviceCommandService.java

@@ -15,5 +15,5 @@ import org.springframework.web.bind.annotation.RequestParam;
  */
 public interface DmpDeviceCommandService extends CrudService<DmpDeviceCommand> {
 
-    CommonPage<DmpDeviceCommand> deviceCommandRecord(Integer commandStatus,String productCode,String deviceId,String startTime,String endTime,Integer pageNum,Integer pageSize);
+    CommonPage<DmpDeviceCommand> deviceCommandRecord(Integer commandStatus,String productCode,String deviceId,String userName,String startTime,String endTime,Integer pageNum,Integer pageSize);
 }

+ 1 - 1
data-transfer/data-transfer-biz/src/main/java/com/usky/transfer/service/QueryInfluxdbDataService.java

@@ -18,6 +18,6 @@ public interface QueryInfluxdbDataService extends CrudService<QueryInfluxdbData>
 
     Map<String,Object> sendDeviceDataToMQ(DeviceDataWriteVO writeVO);
 
-    Map<String,Object> deviceControl(String productCode, String deviceId, String commandStr,Integer tenantId);
+    Map<String,Object> deviceControl(String productCode, String deviceId, String commandStr,Integer tenantId, Long userId, String userName);
 
 }

+ 2 - 1
data-transfer/data-transfer-biz/src/main/java/com/usky/transfer/service/impl/DmpDeviceCommandServiceImpl.java

@@ -25,12 +25,13 @@ import org.springframework.stereotype.Service;
 public class DmpDeviceCommandServiceImpl extends AbstractCrudService<DmpDeviceCommandMapper, DmpDeviceCommand> implements DmpDeviceCommandService {
 
     @Override
-    public CommonPage<DmpDeviceCommand> deviceCommandRecord(Integer commandStatus,String productCode,String deviceId, String startTime, String endTime, Integer pageNum, Integer pageSize){
+    public CommonPage<DmpDeviceCommand> deviceCommandRecord(Integer commandStatus,String productCode,String deviceId, String userName, String startTime, String endTime, Integer pageNum, Integer pageSize){
         IPage<DmpDeviceCommand> page = new Page<>(pageNum,pageSize);
         LambdaQueryWrapper<DmpDeviceCommand> queryWrapper = Wrappers.lambdaQuery();
         queryWrapper.eq(commandStatus != null,DmpDeviceCommand::getCommandStatus,commandStatus)
                 .like(StringUtils.isNotBlank(productCode),DmpDeviceCommand::getProductCode,productCode)
                 .like(StringUtils.isNotBlank(deviceId),DmpDeviceCommand::getDeviceId,deviceId)
+                .like(StringUtils.isNotBlank(userName),DmpDeviceCommand::getUserName,userName)
                 .between(StringUtils.isNotBlank(startTime)&&StringUtils.isNotBlank(endTime),DmpDeviceCommand::getCreatedTime,startTime,endTime)
                 .eq(DmpDeviceCommand::getTenantId, SecurityUtils.getTenantId())
                 .orderByDesc(DmpDeviceCommand::getId);

+ 3 - 1
data-transfer/data-transfer-biz/src/main/java/com/usky/transfer/service/impl/QueryInfluxdbDataServiceImpl.java

@@ -56,7 +56,7 @@ public class QueryInfluxdbDataServiceImpl extends AbstractCrudService<QueryInflu
     private MqttOutConfig.MqttGateway mqttGateway;
 
     @Override
-    public Map<String,Object> deviceControl(String productCode, String deviceId, String commandStr,Integer tenantId){
+    public Map<String,Object> deviceControl(String productCode, String deviceId, String commandStr,Integer tenantId, Long userId, String userName){
         Map<String,Object> rec_map = new HashMap<>();
 
 
@@ -74,6 +74,8 @@ public class QueryInfluxdbDataServiceImpl extends AbstractCrudService<QueryInflu
 //        }
 
         command.setTenantId(tenantId);
+        command.setUserId(userId);
+        command.setUserName(userName);
         dmpDeviceCommandService.save(command);
         int commandId = command.getId();
 

+ 2 - 0
data-transfer/data-transfer-biz/src/main/resources/mapper/transfer/DmpDeviceCommandMapper.xml

@@ -16,6 +16,8 @@
         <result column="updated_time" property="updatedTime" />
         <result column="dept_id" property="deptId" />
         <result column="tenant_id" property="tenantId" />
+        <result column="user_name" property="userName" />
+        <result column="user_id" property="userId" />
     </resultMap>
 
 </mapper>