后台管理添加体温上报
This commit is contained in:
@@ -1,18 +1,31 @@
|
||||
package com.cxyxiaomo.epp.access.controller;
|
||||
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.cxyxiaomo.epp.PageTable.enums.AddType;
|
||||
import com.cxyxiaomo.epp.PageTable.enums.EditType;
|
||||
import com.cxyxiaomo.epp.PageTable.enums.FieldType;
|
||||
import com.cxyxiaomo.epp.PageTable.enums.SearchType;
|
||||
import com.cxyxiaomo.epp.PageTable.query.PageQuery;
|
||||
import com.cxyxiaomo.epp.PageTable.utils.FieldBuilder;
|
||||
import com.cxyxiaomo.epp.PageTable.utils.FieldMapperBuilder;
|
||||
import com.cxyxiaomo.epp.access.rpc.UserServiceFeign;
|
||||
import com.cxyxiaomo.epp.access.service.ReportServiceImpl;
|
||||
import com.cxyxiaomo.epp.common.pojo.Report;
|
||||
import com.cxyxiaomo.epp.common.pojo.User;
|
||||
import com.cxyxiaomo.epp.common.query.ReportQuery;
|
||||
import com.cxyxiaomo.epp.common.response.Res;
|
||||
import com.cxyxiaomo.epp.common.vo.ReportVO;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
@Controller
|
||||
@@ -78,6 +91,7 @@ public class ReportController {
|
||||
List<Report> records = reportService.getRecordListByUserId(user.getId());
|
||||
return Res.success(records);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取最近一次用户填报信息
|
||||
*
|
||||
@@ -94,4 +108,104 @@ public class ReportController {
|
||||
Report records = reportService.getLatestRecordByUserId(user.getId());
|
||||
return Res.success(records);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取体温数据列表
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/manage/getReportList")
|
||||
@ResponseBody
|
||||
public Res getReportList(PageQuery pageQuery, ReportQuery reportQuery) {
|
||||
// 查询分页数据
|
||||
PageHelper.startPage(pageQuery.getPageIndex(), pageQuery.getPageSize());
|
||||
List<Report> reportList = reportService.getReportList(reportQuery);
|
||||
PageInfo<Report> reportPageInfo = new PageInfo<>(reportList);
|
||||
List<Report> list = reportPageInfo.getList();
|
||||
List<ReportVO> voList = ReportVO.convertFrom(list);
|
||||
|
||||
// id列 字段名(区分大小写;以VO中的变量名为准)
|
||||
// 新增、修改弹窗时,使用该列作为主键列进行操作
|
||||
String idFieldName = "id";
|
||||
|
||||
// 当前管理页面
|
||||
String pageName = "体温上报管理";
|
||||
|
||||
// 指定前端表格显示列
|
||||
JSONArray columns = FieldBuilder.create()
|
||||
.add("timestamp", "timestamp", "打卡时间", "",
|
||||
FieldType.DATETIME, SearchType.DATETIME_INTERVAL, AddType.CAN_NOT_ADD, EditType.CAN_NOT_EDIT,
|
||||
FieldBuilder.SEARCH_PLACEHOLDER_SAME_AS_FIELDNAME,
|
||||
null, null, null, null
|
||||
)
|
||||
.add("userId", "userId", "用户id", "",
|
||||
FieldType.TEXT, SearchType.INPUT, AddType.CAN_NOT_ADD, EditType.CAN_NOT_EDIT,
|
||||
FieldBuilder.SEARCH_PLACEHOLDER_SAME_AS_FIELDNAME,
|
||||
null, null, null, null
|
||||
)
|
||||
.add("name", "name", "用户姓名", "",
|
||||
FieldType.TEXT, SearchType.INPUT, AddType.CAN_NOT_ADD, EditType.CAN_NOT_EDIT,
|
||||
FieldBuilder.SEARCH_PLACEHOLDER_SAME_AS_FIELDNAME,
|
||||
null, null, null, null
|
||||
)
|
||||
.add("temperature", "displayTemperature", "状态", "",
|
||||
FieldType.TEXT, SearchType.SELECT, AddType.CAN_NOT_ADD, EditType.CAN_NOT_EDIT,
|
||||
FieldBuilder.SEARCH_PLACEHOLDER_SAME_AS_FIELDNAME,
|
||||
null, null, null, null
|
||||
)
|
||||
.add("address", "address", "地址", "",
|
||||
FieldType.LONG_TEXT, SearchType.INPUT, AddType.CAN_NOT_ADD, EditType.CAN_NOT_EDIT,
|
||||
FieldBuilder.SEARCH_PLACEHOLDER_SAME_AS_FIELDNAME,
|
||||
null, null, null, null
|
||||
)
|
||||
.build();
|
||||
|
||||
// 指定需要翻译的字段
|
||||
HashMap<Object, Object> stateMap = new HashMap<>(2);
|
||||
stateMap.put("0", "正常");
|
||||
stateMap.put("1", "异常(≥37.3℃)");
|
||||
// build
|
||||
JSONArray fieldMapper = FieldMapperBuilder.create()
|
||||
.add("temperature", "displayTemperature", stateMap)
|
||||
.build();
|
||||
|
||||
// 拼装返回结果
|
||||
JSONObject map = new JSONObject(6);
|
||||
map.put("total", reportPageInfo.getTotal());
|
||||
map.put("list", voList);
|
||||
map.put("columns", columns);
|
||||
map.put("fieldMapper", fieldMapper);
|
||||
map.put("idFieldName", idFieldName);
|
||||
map.put("pageName", pageName);
|
||||
|
||||
map.put("pawQuery", pageName);
|
||||
|
||||
// 返回结果
|
||||
return Res.success(map);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出商品列表
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/manage/exportReportList")
|
||||
@ResponseBody
|
||||
public Res exportReportList(ReportQuery reportQuery) {
|
||||
List<Report> reportList = reportService.getReportList(reportQuery);
|
||||
List<ReportVO> reportVOList = ReportVO.convertFrom(reportList);
|
||||
|
||||
// 当前时间
|
||||
Date now = Calendar.getInstance().getTime();
|
||||
SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd_HHmmss");
|
||||
String dateTime = format.format(now);
|
||||
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("list", reportVOList);
|
||||
map.put("sheetName", "体温数据表-" + System.currentTimeMillis());
|
||||
map.put("fileName", "体温数据表_导出时间_" + dateTime);
|
||||
|
||||
return Res.success(map);
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package com.cxyxiaomo.epp.access.dao;
|
||||
|
||||
import com.cxyxiaomo.epp.common.pojo.Report;
|
||||
import com.cxyxiaomo.epp.common.query.ReportQuery;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@@ -14,4 +15,6 @@ public interface ReportDao {
|
||||
List<Report> getReportListByUserId(Integer userId);
|
||||
|
||||
Report getLatestReportByUserId(Integer userId);
|
||||
|
||||
public List<Report> getReportList(ReportQuery reportQuery);
|
||||
}
|
||||
|
@@ -2,6 +2,8 @@ package com.cxyxiaomo.epp.access.service;
|
||||
|
||||
import com.cxyxiaomo.epp.access.dao.ReportDao;
|
||||
import com.cxyxiaomo.epp.common.pojo.Report;
|
||||
import com.cxyxiaomo.epp.common.query.ReportQuery;
|
||||
import com.cxyxiaomo.epp.common.vo.ReportVO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -18,11 +20,19 @@ public class ReportServiceImpl implements ReportService {
|
||||
reportDao.insert(report);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Report> getRecordListByUserId(Integer userId) {
|
||||
return reportDao.getReportListByUserId(userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Report getLatestRecordByUserId(Integer userId) {
|
||||
return reportDao.getLatestReportByUserId(userId);
|
||||
}
|
||||
|
||||
|
||||
public List<Report> getReportList(ReportQuery reportQuery) {
|
||||
List<Report> reportList = reportDao.getReportList(reportQuery);
|
||||
return reportList;
|
||||
}
|
||||
}
|
||||
|
@@ -21,3 +21,8 @@ spring:
|
||||
url: jdbc:mysql://127.0.0.1:3306/epp?useUnicode=true&characterEncoding=utf8&useSSL=false
|
||||
username: root
|
||||
password: root
|
||||
|
||||
logging:
|
||||
level:
|
||||
org.mybatis.spring.SqlSessionFactoryBean: DEBUG
|
||||
# org.mybatis.spring.SqlSessionFactoryBean: TRACE
|
||||
|
@@ -18,4 +18,33 @@
|
||||
order by time desc
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
|
||||
<select id="getReportList" resultType="com.cxyxiaomo.epp.common.pojo.Report">
|
||||
select *
|
||||
from report
|
||||
where 1 = 1
|
||||
<if test="id != null">
|
||||
AND id = #{id}
|
||||
</if>
|
||||
<if test="userId != null">
|
||||
AND user_id = #{userId}
|
||||
</if>
|
||||
<if test="name != null && name != ''">
|
||||
AND name LIKE concat('%',#{name,jdbcType=VARCHAR},'%')
|
||||
</if>
|
||||
<!--<if test="timestamp != null">-->
|
||||
<!-- AND DATE_FORMAT(time, '%Y-%m-%d %H:%i:%s') = #{time, jdbcType=TIMESTAMP}-->
|
||||
<!--</if>-->
|
||||
<if test="startTime != null && endTime != null">
|
||||
AND time BETWEEN from_unixtime(#{startTime}/1000) AND from_unixtime(#{endTime}/1000)
|
||||
</if>
|
||||
<if test="temperature != null">
|
||||
AND temperature = #{temperature}
|
||||
</if>
|
||||
<if test="address != null && address != ''">
|
||||
AND address LIKE concat('%',#{address,jdbcType=VARCHAR},'%')
|
||||
</if>
|
||||
ORDER BY time desc
|
||||
</select>
|
||||
</mapper>
|
||||
|
@@ -9,5 +9,9 @@
|
||||
|
||||
<!--下划线转小驼峰-->
|
||||
<setting name="mapUnderscoreToCamelCase" value="true"/>
|
||||
|
||||
<!-- 打印 SQL 日志 -->
|
||||
<!-- 设置logImpl为STDOUT_LOGGING,表示使用标准输出打印SQL日志 -->
|
||||
<setting name="logImpl" value="STDOUT_LOGGING"/>
|
||||
</settings>
|
||||
</configuration>
|
||||
|
Reference in New Issue
Block a user