1. 意见反馈

2. 客服电话
This commit is contained in:
邱贞招 2024-10-18 21:59:28 +08:00
parent 3889f1928b
commit 42799b0e26
14 changed files with 876 additions and 87 deletions

View File

@ -27,7 +27,7 @@ import javax.annotation.Resource;
* @author ruoyi
*/
@RestController
@RequestMapping("/app")
@RequestMapping("/appVerify")
public class AsProfileController extends BaseController
{

View File

@ -2,7 +2,7 @@ package com.ruoyi.common.enums;
/**
* 业务操作类型
*
*
* @author ruoyi
*/
public enum BusinessType
@ -51,9 +51,14 @@ public enum BusinessType
* 生成代码
*/
GENCODE,
/**
* 清空数据
*/
CLEAN,
/**
* 意见反馈
*/
FEEDBACK
}

View File

@ -3,7 +3,7 @@
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.system.mapper.SysConfigMapper">
<resultMap type="SysConfig" id="SysConfigResult">
<id property="configId" column="config_id" />
<result property="configName" column="config_name" />
@ -15,12 +15,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
</resultMap>
<sql id="selectConfigVo">
select config_id, config_name, config_key, config_value, config_type, create_by, create_time, update_by, update_time, remark
select config_id, config_name, config_key, config_value, config_type, create_by, create_time, update_by, update_time, remark
from sys_config
</sql>
<!-- 查询条件 -->
<sql id="sqlwhereSearch">
<where>
@ -32,12 +32,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</if>
</where>
</sql>
<select id="selectConfig" parameterType="SysConfig" resultMap="SysConfigResult">
<include refid="selectConfigVo"/>
<include refid="sqlwhereSearch"/>
</select>
<select id="selectConfigList" parameterType="SysConfig" resultMap="SysConfigResult">
<include refid="selectConfigVo"/>
<where>
@ -57,18 +57,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
and date_format(create_time,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d')
</if>
</where>
order by create_time desc
</select>
<select id="selectConfigById" parameterType="Long" resultMap="SysConfigResult">
<include refid="selectConfigVo"/>
where config_id = #{configId}
</select>
<select id="checkConfigKeyUnique" parameterType="String" resultMap="SysConfigResult">
<include refid="selectConfigVo"/>
where config_key = #{configKey} limit 1
</select>
<insert id="insertConfig" parameterType="SysConfig">
insert into sys_config (
<if test="configName != null and configName != '' ">config_name,</if>
@ -88,9 +89,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
sysdate()
)
</insert>
<update id="updateConfig" parameterType="SysConfig">
update sys_config
update sys_config
<set>
<if test="configName != null and configName != ''">config_name = #{configName},</if>
<if test="configKey != null and configKey != ''">config_key = #{configKey},</if>
@ -102,16 +103,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</set>
where config_id = #{configId}
</update>
<delete id="deleteConfigById" parameterType="Long">
delete from sys_config where config_id = #{configId}
</delete>
<delete id="deleteConfigByIds" parameterType="Long">
delete from sys_config where config_id in
delete from sys_config where config_id in
<foreach item="configId" collection="array" open="(" separator="," close=")">
#{configId}
</foreach>
</delete>
</mapper>
</mapper>

View File

@ -0,0 +1,44 @@
import request from '@/utils/request'
// 查询反馈意见列表
export function listFeedback(query) {
return request({
url: '/system/feedback/list',
method: 'get',
params: query
})
}
// 查询反馈意见详细
export function getFeedback(feedbackId) {
return request({
url: '/system/feedback/' + feedbackId,
method: 'get'
})
}
// 新增反馈意见
export function addFeedback(data) {
return request({
url: '/system/feedback',
method: 'post',
data: data
})
}
// 修改反馈意见
export function updateFeedback(data) {
return request({
url: '/system/feedback',
method: 'put',
data: data
})
}
// 删除反馈意见
export function delFeedback(feedbackId) {
return request({
url: '/system/feedback/' + feedbackId,
method: 'delete'
})
}

View File

@ -0,0 +1,247 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="反馈类型" prop="type">
<el-select v-model="queryParams.type" placeholder="请选择反馈类型" clearable>
<el-option
v-for="dict in dict.type.as_feedback_type"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
<el-form-item label="联系方式" prop="contactInfo">
<el-input
v-model="queryParams.contactInfo"
placeholder="请输入联系方式"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="操作人" prop="createBy">
<el-input
v-model="queryParams.createBy"
placeholder="请输入操作人"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-download"
size="mini"
@click="handleExport"
v-hasPermi="['system:feedback:export']"
>导出</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="feedbackList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="反馈ID" align="center" prop="feedbackId" />
<el-table-column label="反馈类型" align="center" prop="type">
<template slot-scope="scope">
<dict-tag :options="dict.type.as_feedback_type" :value="scope.row.type"/>
</template>
</el-table-column>
<el-table-column label="问题描述" align="center" prop="issueDescription" />
<el-table-column label="上传图片" align="center" prop="uploadedImage" width="100">
<template slot-scope="scope">
<image-preview :src="scope.row.uploadedImage" :width="50" :height="50"/>
</template>
</el-table-column>
<el-table-column label="联系方式" align="center" prop="contactInfo" />
<el-table-column label="操作人" align="center" prop="createBy" />
<el-table-column label="创建时间" align="center" prop="createTime" width="180">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<!-- 添加或修改反馈意见对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { listFeedback, getFeedback, delFeedback, addFeedback, updateFeedback } from "@/api/system/feedback";
export default {
name: "Feedback",
dicts: ['as_feedback_type'],
data() {
return {
//
loading: true,
//
ids: [],
//
single: true,
//
multiple: true,
//
showSearch: true,
//
total: 0,
//
feedbackList: [],
//
title: "",
//
open: false,
//
queryParams: {
pageNum: 1,
pageSize: 10,
type: null,
contactInfo: null,
createBy: null,
},
//
form: {},
//
rules: {
type: [
{ required: true, message: "反馈类型不能为空", trigger: "change" }
],
issueDescription: [
{ required: true, message: "问题描述不能为空", trigger: "blur" }
],
createBy: [
{ required: true, message: "操作人不能为空", trigger: "blur" }
],
createTime: [
{ required: true, message: "创建时间不能为空", trigger: "blur" }
]
}
};
},
created() {
this.getList();
},
methods: {
/** 查询反馈意见列表 */
getList() {
this.loading = true;
listFeedback(this.queryParams).then(response => {
this.feedbackList = response.rows;
this.total = response.total;
this.loading = false;
});
},
//
cancel() {
this.open = false;
this.reset();
},
//
reset() {
this.form = {
feedbackId: null,
type: null,
issueDescription: null,
uploadedImage: null,
contactInfo: null,
createBy: null,
createTime: null
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
//
handleSelectionChange(selection) {
this.ids = selection.map(item => item.feedbackId)
this.single = selection.length!==1
this.multiple = !selection.length
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "添加反馈意见";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const feedbackId = row.feedbackId || this.ids
getFeedback(feedbackId).then(response => {
this.form = response.data;
this.open = true;
this.title = "修改反馈意见";
});
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.feedbackId != null) {
updateFeedback(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
});
} else {
addFeedback(this.form).then(response => {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
});
}
}
});
},
/** 删除按钮操作 */
handleDelete(row) {
const feedbackIds = row.feedbackId || this.ids;
this.$modal.confirm('是否确认删除反馈意见编号为"' + feedbackIds + '"的数据项?').then(function() {
return delFeedback(feedbackIds);
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
},
/** 导出按钮操作 */
handleExport() {
this.download('system/feedback/export', {
...this.queryParams
}, `feedback_${new Date().getTime()}.xlsx`)
}
}
};
</script>

View File

@ -35,9 +35,9 @@ module.exports = {
proxy: {
// detail: https://cli.vuejs.org/config/#devserver-proxy
[process.env.VUE_APP_BASE_API]: {
// target: `http://localhost:8081`,
target: `http://localhost:8081`,
// target: `http://117.50.215.20:8080`,
target:`https://yxd.ccttiot.com/prod-api/`,
// target:`https://yxd.ccttiot.com/prod-api/`,
// target:`http://192.168.2.5:8081`,
changeOrigin: true,
pathRewrite: {

View File

@ -6,6 +6,7 @@ import com.alibaba.fastjson2.JSONObject;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.AsArticleClassify;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.baidu.GetToken;
@ -14,6 +15,7 @@ import com.ruoyi.common.utils.ip.IpUtils;
import com.ruoyi.device.domain.*;
import com.ruoyi.device.domain.vo.IdentifyRes;
import com.ruoyi.device.service.*;
import com.ruoyi.system.service.ISysConfigService;
import lombok.SneakyThrows;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired;
@ -68,6 +70,15 @@ public class AppController extends BaseController
@Autowired
private IAsModelService asModelService;
@Autowired
private IAsArticleClassifyService asArticleClassifyService;
@Autowired
private ISysConfigService configService;
@Resource
private IAsFeedbackService asFeedbackService;
@Value(value = "${baidu.identifyUrl}")
private String identifyUrl;
@ -75,13 +86,32 @@ public class AppController extends BaseController
* 查询文章列表
*/
@GetMapping("/article/list")
public TableDataInfo list(AsArticle asArticle)
public TableDataInfo articleList(AsArticle asArticle)
{
startPage();
List<AsArticle> list = asArticleService.selectAsArticleList(asArticle);
return getDataTable(list);
}
/**
* 获取分类列表
*/
@GetMapping("/articleClassify/list")
public AjaxResult articleClassifyList(AsArticleClassify asArticleClassify)
{
List<AsArticleClassify> asArticleClassifies = asArticleClassifyService.selectClassifyList(asArticleClassify);
return success(asArticleClassifies);
}
/**
* 获取文章详细信息
*/
@GetMapping(value = "/article/{articleId}")
public AjaxResult getArticleInfo(@PathVariable("articleId") Long articleId)
{
return success(asArticleService.selectAsArticleByArticleId(articleId));
}
/**
* 根据登录用户获取绑定设备
@ -412,4 +442,28 @@ public class AppController extends BaseController
return AjaxResult.success(asDevices);
}
/**
* 客服电话
*/
@GetMapping("/getServerPhone")
public AjaxResult getServerPhone()
{
logger.info("客服电话-----");
AjaxResult success = AjaxResult.success();
String phone = configService.selectConfigByKey("rl.server.phone");
success.put(AjaxResult.DATA_TAG,phone);
return success;
}
/**
* 新增反馈意见
*/
@Log(title = "反馈意见", businessType = BusinessType.INSERT)
@PostMapping("/feedback")
public AjaxResult add(@RequestBody AsFeedback asFeedback)
{
return toAjax(asFeedbackService.insertAsFeedback(asFeedback));
}
}

View File

@ -0,0 +1,98 @@
package com.ruoyi.device.controller;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.device.domain.AsFeedback;
import com.ruoyi.device.service.IAsFeedbackService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
* 反馈意见Controller
*
* @author qzz
* @date 2024-10-18
*/
@RestController
@RequestMapping("/system/feedback")
public class AsFeedbackController extends BaseController
{
@Resource
private IAsFeedbackService asFeedbackService;
/**
* 查询反馈意见列表
*/
@PreAuthorize("@ss.hasPermi('system:feedback:list')")
@GetMapping("/list")
public TableDataInfo list(AsFeedback asFeedback)
{
startPage();
List<AsFeedback> list = asFeedbackService.selectAsFeedbackList(asFeedback);
return getDataTable(list);
}
/**
* 导出反馈意见列表
*/
@PreAuthorize("@ss.hasPermi('system:feedback:export')")
@Log(title = "反馈意见", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, AsFeedback asFeedback)
{
List<AsFeedback> list = asFeedbackService.selectAsFeedbackList(asFeedback);
ExcelUtil<AsFeedback> util = new ExcelUtil<AsFeedback>(AsFeedback.class);
util.exportExcel(response, list, "反馈意见数据");
}
/**
* 获取反馈意见详细信息
*/
@PreAuthorize("@ss.hasPermi('system:feedback:query')")
@GetMapping(value = "/{feedbackId}")
public AjaxResult getInfo(@PathVariable("feedbackId") Long feedbackId)
{
return success(asFeedbackService.selectAsFeedbackByFeedbackId(feedbackId));
}
/**
* 新增反馈意见
*/
@PreAuthorize("@ss.hasPermi('system:feedback:add')")
@Log(title = "反馈意见", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody AsFeedback asFeedback)
{
return toAjax(asFeedbackService.insertAsFeedback(asFeedback));
}
/**
* 修改反馈意见
*/
@PreAuthorize("@ss.hasPermi('system:feedback:edit')")
@Log(title = "反馈意见", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody AsFeedback asFeedback)
{
return toAjax(asFeedbackService.updateAsFeedback(asFeedback));
}
/**
* 删除反馈意见
*/
@PreAuthorize("@ss.hasPermi('system:feedback:remove')")
@Log(title = "反馈意见", businessType = BusinessType.DELETE)
@DeleteMapping("/{feedbackIds}")
public AjaxResult remove(@PathVariable Long[] feedbackIds)
{
return toAjax(asFeedbackService.deleteAsFeedbackByFeedbackIds(feedbackIds));
}
}

View File

@ -0,0 +1,38 @@
package com.ruoyi.device.domain;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
import lombok.Data;
/**
* 反馈意见对象 as_feedback
*
* @author qzz
* @date 2024-10-18
*/
@Data
public class AsFeedback extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 反馈ID */
@Excel(name = "反馈ID")
private Long feedbackId;
/** 反馈类型 */
@Excel(name = "反馈类型")
private String type;
/** 问题描述 */
@Excel(name = "问题描述")
private String issueDescription;
/** 上传图片 */
@Excel(name = "上传图片")
private String uploadedImage;
/** 联系方式 */
@Excel(name = "联系方式")
private String contactInfo;
}

View File

@ -0,0 +1,62 @@
package com.ruoyi.device.mapper;
import java.util.List;
import com.ruoyi.device.domain.AsFeedback;
/**
* 反馈意见Mapper接口
*
* @author qzz
* @date 2024-10-18
*/
public interface AsFeedbackMapper
{
/**
* 查询反馈意见
*
* @param feedbackId 反馈意见主键
* @return 反馈意见
*/
public AsFeedback selectAsFeedbackByFeedbackId(Long feedbackId);
/**
* 查询反馈意见列表
*
* @param asFeedback 反馈意见
* @return 反馈意见集合
*/
public List<AsFeedback> selectAsFeedbackList(AsFeedback asFeedback);
/**
* 新增反馈意见
*
* @param asFeedback 反馈意见
* @return 结果
*/
public int insertAsFeedback(AsFeedback asFeedback);
/**
* 修改反馈意见
*
* @param asFeedback 反馈意见
* @return 结果
*/
public int updateAsFeedback(AsFeedback asFeedback);
/**
* 删除反馈意见
*
* @param feedbackId 反馈意见主键
* @return 结果
*/
public int deleteAsFeedbackByFeedbackId(Long feedbackId);
/**
* 批量删除反馈意见
*
* @param feedbackIds 需要删除的数据主键集合
* @return 结果
*/
public int deleteAsFeedbackByFeedbackIds(Long[] feedbackIds);
}

View File

@ -0,0 +1,62 @@
package com.ruoyi.device.service;
import com.ruoyi.device.domain.AsFeedback;
import java.util.List;
/**
* 反馈意见Service接口
*
* @author qzz
* @date 2024-10-18
*/
public interface IAsFeedbackService
{
/**
* 查询反馈意见
*
* @param feedbackId 反馈意见主键
* @return 反馈意见
*/
public AsFeedback selectAsFeedbackByFeedbackId(Long feedbackId);
/**
* 查询反馈意见列表
*
* @param asFeedback 反馈意见
* @return 反馈意见集合
*/
public List<AsFeedback> selectAsFeedbackList(AsFeedback asFeedback);
/**
* 新增反馈意见
*
* @param asFeedback 反馈意见
* @return 结果
*/
public int insertAsFeedback(AsFeedback asFeedback);
/**
* 修改反馈意见
*
* @param asFeedback 反馈意见
* @return 结果
*/
public int updateAsFeedback(AsFeedback asFeedback);
/**
* 批量删除反馈意见
*
* @param feedbackIds 需要删除的反馈意见主键集合
* @return 结果
*/
public int deleteAsFeedbackByFeedbackIds(Long[] feedbackIds);
/**
* 删除反馈意见信息
*
* @param feedbackId 反馈意见主键
* @return 结果
*/
public int deleteAsFeedbackByFeedbackId(Long feedbackId);
}

View File

@ -0,0 +1,100 @@
package com.ruoyi.device.service.impl;
import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.device.domain.AsFeedback;
import com.ruoyi.device.mapper.AsFeedbackMapper;
import com.ruoyi.device.service.IAsFeedbackService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import static com.ruoyi.common.utils.SecurityUtils.getUsername;
/**
* 反馈意见Service业务层处理
*
* @author qzz
* @date 2024-10-18
*/
@Service
public class AsFeedbackServiceImpl implements IAsFeedbackService
{
@Resource
private AsFeedbackMapper asFeedbackMapper;
/**
* 查询反馈意见
*
* @param feedbackId 反馈意见主键
* @return 反馈意见
*/
@Override
public AsFeedback selectAsFeedbackByFeedbackId(Long feedbackId)
{
return asFeedbackMapper.selectAsFeedbackByFeedbackId(feedbackId);
}
/**
* 查询反馈意见列表
*
* @param asFeedback 反馈意见
* @return 反馈意见
*/
@Override
public List<AsFeedback> selectAsFeedbackList(AsFeedback asFeedback)
{
return asFeedbackMapper.selectAsFeedbackList(asFeedback);
}
/**
* 新增反馈意见
*
* @param asFeedback 反馈意见
* @return 结果
*/
@Override
public int insertAsFeedback(AsFeedback asFeedback)
{
asFeedback.setCreateTime(DateUtils.getNowDate());
asFeedback.setCreateBy(getUsername());
return asFeedbackMapper.insertAsFeedback(asFeedback);
}
/**
* 修改反馈意见
*
* @param asFeedback 反馈意见
* @return 结果
*/
@Override
public int updateAsFeedback(AsFeedback asFeedback)
{
return asFeedbackMapper.updateAsFeedback(asFeedback);
}
/**
* 批量删除反馈意见
*
* @param feedbackIds 需要删除的反馈意见主键
* @return 结果
*/
@Override
public int deleteAsFeedbackByFeedbackIds(Long[] feedbackIds)
{
return asFeedbackMapper.deleteAsFeedbackByFeedbackIds(feedbackIds);
}
/**
* 删除反馈意见信息
*
* @param feedbackId 反馈意见主键
* @return 结果
*/
@Override
public int deleteAsFeedbackByFeedbackId(Long feedbackId)
{
return asFeedbackMapper.deleteAsFeedbackByFeedbackId(feedbackId);
}
}

View File

@ -442,71 +442,71 @@ public class AsUserServiceImpl implements IAsUserService
AsDevice asDevice = AsDevice.builder().userId(userId).isDefault(isDefault).build();
List<AsDevice> asDevices = asDeviceMapper.selectAsDeviceList(asDevice);
// 查询onenet设备在线状态
String sendUrl = iotUrl+ IotConstants.ADDS_COMMAND;
String token = Token.getToken();
for(AsDevice asDevice1 : asDevices){
String deviceName = asDevice1.getMac();//mac地址就是产品名称
String param = "device_name=" + deviceName + "&product_id=" + productId +"&timeout=" + timeout;
sendUrl = sendUrl + "?"+param;
String result = HttpUtils.sendPostWithToken(sendUrl, "111", token);
JSONObject paramsObj = JSON.parseObject(result);
String code = paramsObj.getString("code");
if (!HttpStatus.IOT_SUCCESS.equals(code)) {
asDevice1.setOnlineStatus("0");//在线状态0-不在线1-在线
return asDevices;
}else{
asDevice1.setOnlineStatus("1");
// 查询onenet设备参数
String datapointsUrl = iotUrl+ IotConstants.ADDS_HISTORY_DATAPOINTS + "?"+param;
log.info("IOT获取到Authorization:【{}】", token);
String result2 = HttpUtils.sendGetWithToken(datapointsUrl, null, token);
DataPointRes dataPointRes = JSONObject.parseObject(result2, DataPointRes.class);
Data data = dataPointRes.getData();
List<Datastream> datastreams = data.getDatastreams();
for (Datastream datastream: datastreams) {
if(datastream.getId().equals("jj")){
List<Datapoint> datapoints = datastream.getDatapoints();
Datapoint datapoint = datapoints.get(0);
DatapointValue value = JSONObject.parseObject(datapoint.getValue().toString(), DatapointValue.class);
asDevice1.setWaterIntensity(value.getJiaoshui_qiangdu());
DatapointValue.Tr tr = value.getTr();
asDevice1.setSoilMoistureClose(tr.getEnd_sd());
asDevice1.setSoilMoistureOpen(tr.getStart_sd());
asDevice1.setSoilMoisture(tr.getKaiguan().toString());
asDevice1.setPulseModeParam(JSON.toJSONString(value.getMc()));
DatapointValue.nextDs next_ds = value.getNext_ds();
/**设置下次浇水时间日期*/
setNextDs(asDevice1, next_ds);
/**设置浇水模式*/
List<String> modeList = new ArrayList<>();
Boolean sw = next_ds.getSw();
List<DatapointValue.Ds> dsArray = value.getDsArray();
//清除无效定时器
List<DatapointValue.Ds> ds = asTimerService.cleanInvalidDs(dsArray);
if(sw && ds.size()>0){//如果定时器开启且定时器列表不为空
modeList.add("1");
}
Boolean kaiguan = tr.getKaiguan();
if(kaiguan){//土壤模式开关
modeList.add("2");
}
asDevice1.setMode(modeList);
asDevice1.setModeStr(JSON.toJSONString(modeList));
asDevice1.setCurrentSoilMoisture(value.getTuran_show());
List<AsWateringRecord> asWateringRecords = asWateringRecordService.selectAsWateringRecordList(AsWateringRecord.builder().deviceId(asDevice1.getDeviceId()).build());
// 根据asWateringRecords查询最后一次浇水时间
if(asWateringRecords.size()>0){
asDevice1.setLastWatering(asWateringRecords.get(0).getWaterTime());
}
/**将value转成device对象并保存到数据库*/
int i = asDeviceMapper.updateAsDevice(asDevice1);
if(i>0){
log.info("保存设备参数成功:【{}】", JSON.toJSONString(asDevice1));
}
}
}
}
}
// String sendUrl = iotUrl+ IotConstants.ADDS_COMMAND;
// String token = Token.getToken();
// for(AsDevice asDevice1 : asDevices){
// String deviceName = asDevice1.getMac();//mac地址就是产品名称
// String param = "device_name=" + deviceName + "&product_id=" + productId +"&timeout=" + timeout;
// sendUrl = sendUrl + "?"+param;
// String result = HttpUtils.sendPostWithToken(sendUrl, "111", token);
// JSONObject paramsObj = JSON.parseObject(result);
// String code = paramsObj.getString("code");
// if (!HttpStatus.IOT_SUCCESS.equals(code)) {
// asDevice1.setOnlineStatus("0");//在线状态0-不在线1-在线
// return asDevices;
// }else{
// asDevice1.setOnlineStatus("1");
// // 查询onenet设备参数
// String datapointsUrl = iotUrl+ IotConstants.ADDS_HISTORY_DATAPOINTS + "?"+param;
// log.info("IOT获取到Authorization:【{}】", token);
// String result2 = HttpUtils.sendGetWithToken(datapointsUrl, null, token);
// DataPointRes dataPointRes = JSONObject.parseObject(result2, DataPointRes.class);
// Data data = dataPointRes.getData();
// List<Datastream> datastreams = data.getDatastreams();
// for (Datastream datastream: datastreams) {
// if(datastream.getId().equals("jj")){
// List<Datapoint> datapoints = datastream.getDatapoints();
// Datapoint datapoint = datapoints.get(0);
// DatapointValue value = JSONObject.parseObject(datapoint.getValue().toString(), DatapointValue.class);
// asDevice1.setWaterIntensity(value.getJiaoshui_qiangdu());
// DatapointValue.Tr tr = value.getTr();
// asDevice1.setSoilMoistureClose(tr.getEnd_sd());
// asDevice1.setSoilMoistureOpen(tr.getStart_sd());
// asDevice1.setSoilMoisture(tr.getKaiguan().toString());
// asDevice1.setPulseModeParam(JSON.toJSONString(value.getMc()));
// DatapointValue.nextDs next_ds = value.getNext_ds();
// /**设置下次浇水时间日期*/
// setNextDs(asDevice1, next_ds);
// /**设置浇水模式*/
// List<String> modeList = new ArrayList<>();
// Boolean sw = next_ds.getSw();
// List<DatapointValue.Ds> dsArray = value.getDsArray();
// //清除无效定时器
// List<DatapointValue.Ds> ds = asTimerService.cleanInvalidDs(dsArray);
// if(sw && ds.size()>0){//如果定时器开启且定时器列表不为空
// modeList.add("1");
// }
// Boolean kaiguan = tr.getKaiguan();
// if(kaiguan){//土壤模式开关
// modeList.add("2");
// }
// asDevice1.setMode(modeList);
// asDevice1.setModeStr(JSON.toJSONString(modeList));
// asDevice1.setCurrentSoilMoisture(value.getTuran_show());
// List<AsWateringRecord> asWateringRecords = asWateringRecordService.selectAsWateringRecordList(AsWateringRecord.builder().deviceId(asDevice1.getDeviceId()).build());
// // 根据asWateringRecords查询最后一次浇水时间
// if(asWateringRecords.size()>0){
// asDevice1.setLastWatering(asWateringRecords.get(0).getWaterTime());
// }
// /**将value转成device对象并保存到数据库*/
// int i = asDeviceMapper.updateAsDevice(asDevice1);
// if(i>0){
// log.info("保存设备参数成功:【{}】", JSON.toJSONString(asDevice1));
// }
// }
// }
// }
// }
return asDevices;
}

View File

@ -0,0 +1,78 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.device.mapper.AsFeedbackMapper">
<resultMap type="AsFeedback" id="AsFeedbackResult">
<result property="feedbackId" column="feedback_id" />
<result property="type" column="type" />
<result property="issueDescription" column="issue_description" />
<result property="uploadedImage" column="uploaded_image" />
<result property="contactInfo" column="contact_info" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
</resultMap>
<sql id="selectAsFeedbackVo">
select feedback_id, type, issue_description, uploaded_image, contact_info, create_by, create_time from as_feedback
</sql>
<select id="selectAsFeedbackList" parameterType="AsFeedback" resultMap="AsFeedbackResult">
<include refid="selectAsFeedbackVo"/>
<where>
<if test="type != null and type != ''"> and type = #{type}</if>
<if test="contactInfo != null and contactInfo != ''"> and contact_info = #{contactInfo}</if>
<if test="createBy != null and createBy != ''"> and create_by = #{createBy}</if>
</where>
</select>
<select id="selectAsFeedbackByFeedbackId" parameterType="Long" resultMap="AsFeedbackResult">
<include refid="selectAsFeedbackVo"/>
where feedback_id = #{feedbackId}
</select>
<insert id="insertAsFeedback" parameterType="AsFeedback" useGeneratedKeys="true" keyProperty="feedbackId">
insert into as_feedback
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="type != null and type != ''">type,</if>
<if test="issueDescription != null and issueDescription != ''">issue_description,</if>
<if test="uploadedImage != null">uploaded_image,</if>
<if test="contactInfo != null">contact_info,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
<if test="createTime != null">create_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="type != null and type != ''">#{type},</if>
<if test="issueDescription != null and issueDescription != ''">#{issueDescription},</if>
<if test="uploadedImage != null">#{uploadedImage},</if>
<if test="contactInfo != null">#{contactInfo},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
</trim>
</insert>
<update id="updateAsFeedback" parameterType="AsFeedback">
update as_feedback
<trim prefix="SET" suffixOverrides=",">
<if test="type != null and type != ''">type = #{type},</if>
<if test="issueDescription != null and issueDescription != ''">issue_description = #{issueDescription},</if>
<if test="uploadedImage != null">uploaded_image = #{uploadedImage},</if>
<if test="contactInfo != null">contact_info = #{contactInfo},</if>
<if test="createBy != null and createBy != ''">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
</trim>
where feedback_id = #{feedbackId}
</update>
<delete id="deleteAsFeedbackByFeedbackId" parameterType="Long">
delete from as_feedback where feedback_id = #{feedbackId}
</delete>
<delete id="deleteAsFeedbackByFeedbackIds" parameterType="String">
delete from as_feedback where feedback_id in
<foreach item="feedbackId" collection="array" open="(" separator="," close=")">
#{feedbackId}
</foreach>
</delete>
</mapper>