From a4cb35efe9e789d575f5605d7ae688426052f96c Mon Sep 17 00:00:00 2001
From: zhanzhiqin <895896009@qq.com>
Date: 星期一, 29 八月 2022 18:10:50 +0800
Subject: [PATCH] 固件升级
---
dao/src/main/java/com/sandu/ximon/dao/domain/RemoteUpdateFile.java | 18 ++++-
dao/src/main/java/com/sandu/ximon/dao/bo/RemoteUpdateFileBo.java | 61 ++++++++++++++++++++
dao/src/main/java/com/sandu/ximon/dao/mapper/RemoteUpdateFileMapper.java | 1
ximon-admin/src/main/java/com/sandu/ximon/admin/controller/WaterQualityDataController.java | 2
ximon-admin/src/main/java/com/sandu/ximon/admin/service/RemoteUpdateService.java | 46 ++++++++++++++-
dao/src/main/resources/mapper/RemoteUpdateFileMapper.xml | 23 +++----
6 files changed, 130 insertions(+), 21 deletions(-)
diff --git a/dao/src/main/java/com/sandu/ximon/dao/bo/RemoteUpdateFileBo.java b/dao/src/main/java/com/sandu/ximon/dao/bo/RemoteUpdateFileBo.java
new file mode 100644
index 0000000..2c8dd62
--- /dev/null
+++ b/dao/src/main/java/com/sandu/ximon/dao/bo/RemoteUpdateFileBo.java
@@ -0,0 +1,61 @@
+package com.sandu.ximon.dao.bo;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.sandu.ximon.dao.domain.RemoteUpdateFile;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.time.LocalDateTime;
+
+/**
+ * @author ZZQ
+ * @date 2022/8/29 17:30
+ */
+@Data
+public class RemoteUpdateFileBo extends RemoteUpdateFile {
+ /**
+ *
+ */
+ private Integer id;
+
+ /**
+ * 涓婁紶鑰呮樀绉�
+ */
+ private String uploadName;
+
+ /**
+ * 鍗囩骇鏂囦欢鍚�
+ */
+ private String filename;
+
+ /**
+ * 杞欢鐗堟湰
+ */
+ private BigDecimal softwareVersion;
+
+ /**
+ * 纭欢鐗堟湰
+ */
+ private BigDecimal hardwareVersion;
+
+ /**
+ * 闃块噷鏂囦欢瀛樺偍鍦板潃
+ */
+ private String aliAddress;
+
+ /**
+ * 鏂囦欢绫诲瀷
+ */
+ private String fileType;
+
+ /**
+ *
+ */
+ private LocalDateTime createTime;
+
+ /**
+ * 鏂囦欢闀垮害
+ */
+ private String fileLength;
+}
diff --git a/dao/src/main/java/com/sandu/ximon/dao/domain/RemoteUpdateFile.java b/dao/src/main/java/com/sandu/ximon/dao/domain/RemoteUpdateFile.java
index 1bffbd1..df3a670 100644
--- a/dao/src/main/java/com/sandu/ximon/dao/domain/RemoteUpdateFile.java
+++ b/dao/src/main/java/com/sandu/ximon/dao/domain/RemoteUpdateFile.java
@@ -4,23 +4,33 @@
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
+
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
+
import lombok.Data;
/**
- *
* @TableName remote_update_file
*/
-@TableName(value ="remote_update_file")
+@TableName(value = "remote_update_file")
@Data
public class RemoteUpdateFile implements Serializable {
/**
- *
+ *
*/
@TableId(type = IdType.AUTO)
private Integer id;
+ /**
+ * 涓婁紶鑰匢D
+ */
+ private Long uploadUserId;
+
+ /**
+ * 涓婁紶鑰呯被鍨嬶紝0锛氱鐞嗗憳锛�1锛氭櫘閫氱敤鎴蜂笂浼�
+ */
+ private Integer uploadUserType;
/**
* 鍗囩骇鏂囦欢鍚�
@@ -48,7 +58,7 @@
private String fileType;
/**
- *
+ *
*/
private LocalDateTime createTime;
diff --git a/dao/src/main/java/com/sandu/ximon/dao/mapper/RemoteUpdateFileMapper.java b/dao/src/main/java/com/sandu/ximon/dao/mapper/RemoteUpdateFileMapper.java
index 64e190e..6fb3ee1 100644
--- a/dao/src/main/java/com/sandu/ximon/dao/mapper/RemoteUpdateFileMapper.java
+++ b/dao/src/main/java/com/sandu/ximon/dao/mapper/RemoteUpdateFileMapper.java
@@ -4,6 +4,7 @@
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
+
/**
* @Entity com.sandu.ximon.dao.domain.RemoteUpdateFile
*/
diff --git a/dao/src/main/resources/mapper/RemoteUpdateFileMapper.xml b/dao/src/main/resources/mapper/RemoteUpdateFileMapper.xml
index 710971c..da7d355 100644
--- a/dao/src/main/resources/mapper/RemoteUpdateFileMapper.xml
+++ b/dao/src/main/resources/mapper/RemoteUpdateFileMapper.xml
@@ -5,19 +5,16 @@
<mapper namespace="com.sandu.ximon.dao.mapper.RemoteUpdateFileMapper">
<resultMap id="BaseResultMap" type="com.sandu.ximon.dao.domain.RemoteUpdateFile">
- <id property="id" column="id" jdbcType="INTEGER"/>
- <result property="filename" column="filename" jdbcType="VARCHAR"/>
- <result property="softwareVersion" column="software_version" jdbcType="DECIMAL"/>
- <result property="hardwareVersion" column="hardware_version" jdbcType="DECIMAL"/>
- <result property="aliAddress" column="ali_address" jdbcType="VARCHAR"/>
- <result property="fileType" column="file_type" jdbcType="VARCHAR"/>
- <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
- <result property="fileLength" column="file_length" jdbcType="VARCHAR"/>
+ <id property="id" column="id" jdbcType="INTEGER"/>
+ <result property="uploadUserId" column="upload_user_id" jdbcType="BIGINT"/>
+ <result property="uploadUserType" column="upload_user_type" jdbcType="INTEGER"/>
+ <result property="filename" column="filename" jdbcType="VARCHAR"/>
+ <result property="softwareVersion" column="software_version" jdbcType="DECIMAL"/>
+ <result property="hardwareVersion" column="hardware_version" jdbcType="DECIMAL"/>
+ <result property="aliAddress" column="ali_address" jdbcType="VARCHAR"/>
+ <result property="fileType" column="file_type" jdbcType="VARCHAR"/>
+ <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
+ <result property="fileLength" column="file_length" jdbcType="VARCHAR"/>
</resultMap>
- <sql id="Base_Column_List">
- id,filename,software_version,
- hardware_version,ali_address,file_type,
- create_time,file_length
- </sql>
</mapper>
diff --git a/ximon-admin/src/main/java/com/sandu/ximon/admin/controller/WaterQualityDataController.java b/ximon-admin/src/main/java/com/sandu/ximon/admin/controller/WaterQualityDataController.java
index 4458695..a0c2e83 100644
--- a/ximon-admin/src/main/java/com/sandu/ximon/admin/controller/WaterQualityDataController.java
+++ b/ximon-admin/src/main/java/com/sandu/ximon/admin/controller/WaterQualityDataController.java
@@ -26,7 +26,7 @@
/**
* 姘磋川鏁版嵁鏌ヨ
*
- * @return
+ * @returnlistWaterQualityData
*/
@GetMapping("/listWaterQualityData")
public ResponseVO<Object> listWaterQualityDataByKeyword(BaseConditionVO baseConditionVO, @RequestParam(value = "keyword", required = false) String keyword) {
diff --git a/ximon-admin/src/main/java/com/sandu/ximon/admin/service/RemoteUpdateService.java b/ximon-admin/src/main/java/com/sandu/ximon/admin/service/RemoteUpdateService.java
index 8dc2415..c53148c 100644
--- a/ximon-admin/src/main/java/com/sandu/ximon/admin/service/RemoteUpdateService.java
+++ b/ximon-admin/src/main/java/com/sandu/ximon/admin/service/RemoteUpdateService.java
@@ -1,7 +1,10 @@
package com.sandu.ximon.admin.service;
+import cn.hutool.core.bean.BeanUtil;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.sandu.common.execption.BusinessException;
import com.sandu.common.service.impl.BaseServiceImpl;
+import com.sandu.common.util.SpringContextHolder;
import com.sandu.ximon.admin.dto.RemoteFileDto;
import com.sandu.ximon.admin.dto.RemoteUpdateTypeDto;
import com.sandu.ximon.admin.manager.iot.frame.A5Frame;
@@ -11,14 +14,19 @@
import com.sandu.ximon.admin.manager.iot.rrpc.enums.RemoteUpdateTypeEnum;
import com.sandu.ximon.admin.manager.iot.rrpc.mainboard.MainBoardInvokeSyncService;
import com.sandu.ximon.admin.manager.iot.rrpc.util.FileProcessingUtils;
+import com.sandu.ximon.admin.security.SecurityUtils;
import com.sandu.ximon.admin.utils.StoreOperationRecordsUtils;
import com.sandu.ximon.admin.utils.StringUtil;
+import com.sandu.ximon.dao.bo.RemoteUpdateFileBo;
+import com.sandu.ximon.dao.domain.Admin;
+import com.sandu.ximon.dao.domain.Client;
import com.sandu.ximon.dao.domain.RemoteUpdateFile;
import com.sandu.ximon.dao.mapper.RemoteUpdateFileMapper;
import org.springframework.stereotype.Service;
import java.io.IOException;
import java.math.BigDecimal;
+import java.util.ArrayList;
import java.util.List;
/**
@@ -27,6 +35,8 @@
*/
@Service
public class RemoteUpdateService extends BaseServiceImpl<RemoteUpdateFileMapper, RemoteUpdateFile> {
+ private RemoteUpdateFileMapper remoteUpdateFileMapper;
+
/**
* 娣诲姞鏂囦欢鏇存柊鍐呭
*
@@ -41,6 +51,8 @@
RemoteUpdateFile remoteUpdateFile = new RemoteUpdateFile();
remoteUpdateFile.setAliAddress(aliAddress);
remoteUpdateFile.setFileType(fileType);
+ remoteUpdateFile.setUploadUserId(SecurityUtils.getUserId());
+ remoteUpdateFile.setUploadUserType(SecurityUtils.getClientId() == null ? 0 : 1);
remoteUpdateFile.setSoftwareVersion(new BigDecimal(softwareVersion).setScale(2, BigDecimal.ROUND_DOWN));
remoteUpdateFile.setHardwareVersion(new BigDecimal(hardwareVersion).setScale(2, BigDecimal.ROUND_DOWN));
remoteUpdateFile.setFilename(filename);
@@ -65,7 +77,7 @@
}
remoteUpdateFile.setFilename(remoteFileName);
boolean update = updateById(remoteUpdateFile);
- if(!update){
+ if (!update) {
throw new BusinessException("淇敼鍥轰欢鍗囩骇鏂囦欢鍚嶅け璐ワ紒");
}
return "淇敼鍥轰欢鍗囩骇鏂囦欢鍚嶆垚鍔燂紒";
@@ -76,8 +88,36 @@
*
* @return
*/
- public List<RemoteUpdateFile> getRemoteFileList() {
- return list();
+ public List<RemoteUpdateFileBo> getRemoteFileList() {
+ List<RemoteUpdateFile> list = list();
+ List<Admin> adminList = SpringContextHolder.getBean(AdminService.class).list();
+ List<Client> clientList = SpringContextHolder.getBean(ClientService.class).list();
+
+ List<RemoteUpdateFileBo> remoteUpdateFileBoList = new ArrayList<>();
+ RemoteUpdateFileBo remoteUpdateFileBo;
+ for (RemoteUpdateFile bean : list) {
+ remoteUpdateFileBo = new RemoteUpdateFileBo();
+ BeanUtil.copyProperties(bean, remoteUpdateFileBo);
+ if (bean.getUploadUserType() == 0) {
+ for (Admin admin : adminList) {
+ if (bean.getUploadUserId().equals(admin.getId())) {
+ remoteUpdateFileBo.setUploadName(admin.getNickName());
+ }
+ }
+
+ } else if (bean.getUploadUserType() == 1) {
+ for (Client client : clientList) {
+ if (bean.getUploadUserId().equals(client.getId())) {
+ remoteUpdateFileBo.setUploadName(client.getClientName());
+ }
+ }
+ } else {
+ remoteUpdateFileBo.setUploadName("鏈煡鐢ㄦ埛锛�");
+ }
+ remoteUpdateFileBoList.add(remoteUpdateFileBo);
+ }
+
+ return remoteUpdateFileBoList;
}
--
Gitblit v1.9.3