2023-05-15 10:18:26 优化完善首页大屏、能源监测的查询接口!

master
魔神煜修罗皇 2 years ago
parent 9663ac8ba4
commit 138037e3cd
  1. 3
      psdc-business/src/main/java/com/psdc/mapper/PsdcThermometerRtdataMapper.java
  2. 2
      psdc-business/src/main/java/com/psdc/service/IPsdcDeviceService.java
  3. 4
      psdc-business/src/main/java/com/psdc/service/impl/PsdcDeviceServiceImpl.java
  4. 55
      psdc-business/src/main/java/com/psdc/service/impl/PsdcThermometerHtdataServiceImpl.java
  5. 2
      psdc-business/src/main/resources/mapper/business/PsdcDeviceMapper.xml
  6. 2
      psdc-business/src/main/resources/mapper/business/PsdcElectricRtdataMapper.xml
  7. 5
      psdc-business/src/main/resources/mapper/business/PsdcThermometerRtdataMapper.xml
  8. 20
      psdc-web/src/main/java/com/psdc/controller/manager/PsdcDeviceController.java
  9. 23
      psdc-web/src/main/java/com/psdc/controller/monitor/TotalElectricMeterController.java

@ -26,7 +26,8 @@ public interface PsdcThermometerRtdataMapper{
PsdcThermometerDataRes queryById(@Param("thermometerRtdataId") Integer thermometerRtdataId, PsdcThermometerDataRes queryById(@Param("thermometerRtdataId") Integer thermometerRtdataId,
@Param("today") String today); @Param("today") String today);
List<PsdcThermometerDataRes> selWenDu(@Param("devType") Integer devType); List<PsdcThermometerDataRes> selWenDu(@Param("userId") Long userId,
@Param("parentId") Integer parentId);
/** /**
* 分页查询指定行数据 * 分页查询指定行数据

@ -21,7 +21,7 @@ public interface IPsdcDeviceService {
* 根据用户id查询设备列表 * 根据用户id查询设备列表
* @return * @return
*/ */
List<PsdcDevice> queryByUserId(); List<PsdcDevice> queryByUserId(Integer parent);
/** /**
* 查询所有设备状态 * 查询所有设备状态

@ -51,8 +51,8 @@ public class PsdcDeviceServiceImpl implements IPsdcDeviceService {
* 根据用户id查询设备列表 * 根据用户id查询设备列表
* @return 设备列表 * @return 设备列表
*/ */
public List<PsdcDevice> queryByUserId() { public List<PsdcDevice> queryByUserId(Integer parent) {
return psdcDeviceMapper.queryByUserId(SecurityUtils.getUserId(), 0); return psdcDeviceMapper.queryByUserId(SecurityUtils.getUserId(), parent);
} }
public List<DeviceStatusVo> queryDeviceStatus() { public List<DeviceStatusVo> queryDeviceStatus() {

@ -53,7 +53,7 @@ public class PsdcThermometerHtdataServiceImpl implements IPsdcThermometerHtdataS
for (Integer d : devList) { for (Integer d : devList) {
// 今日如果无数据,空判断处理 // 今日如果无数据,空判断处理
if (null != psdcThermometerRtdataMapper.queryById(d, sdf.format(date))){ if (null != psdcThermometerRtdataMapper.queryById(d, sdf.format(date))) {
// 查询今日实时温度数据 // 查询今日实时温度数据
PsdcThermometerDataRes dataRes = psdcThermometerRtdataMapper.queryById(d, sdf.format(date)); PsdcThermometerDataRes dataRes = psdcThermometerRtdataMapper.queryById(d, sdf.format(date));
@ -64,18 +64,18 @@ public class PsdcThermometerHtdataServiceImpl implements IPsdcThermometerHtdataS
// 循环遍历今天历史数据对象集合 // 循环遍历今天历史数据对象集合
List<PsdcThermometerHtdata> htdata = psdcThermometerHtdataMapper.selTodayThermometer(d, tb, te); List<PsdcThermometerHtdata> htdata = psdcThermometerHtdataMapper.selTodayThermometer(d, tb, te);
for (PsdcThermometerHtdata h : htdata){ for (PsdcThermometerHtdata h : htdata) {
if (null != h.getThermometerValue()){ if (null != h.getThermometerValue()) {
listTemp.add(h.getThermometerValue()); listTemp.add(h.getThermometerValue());
} }
if (null != h.getThermometerValueIn()){ if (null != h.getThermometerValueIn()) {
listIn.add(h.getThermometerValueIn()); listIn.add(h.getThermometerValueIn());
} }
if (null != h.getThermometerValueOut()){ if (null != h.getThermometerValueOut()) {
listOut.add(h.getThermometerValueOut()); listOut.add(h.getThermometerValueOut());
} }
String t = h.getUpdateTime().split(" ")[1].substring(0,5); String t = h.getUpdateTime().split(" ")[1].substring(0, 5);
times.add(t); times.add(t);
} }
@ -95,7 +95,7 @@ public class PsdcThermometerHtdataServiceImpl implements IPsdcThermometerHtdataS
@Override @Override
public AjaxResult sel8WnDu() { public AjaxResult sel8WnDu() {
List<PsdcThermometerDataRes> dataResList = psdcThermometerRtdataMapper.selWenDu(1); List<PsdcThermometerDataRes> dataResList = psdcThermometerRtdataMapper.selWenDu(SecurityUtils.getUserId(), 16);
return AjaxResult.success(dataResList); return AjaxResult.success(dataResList);
} }
@ -105,7 +105,7 @@ public class PsdcThermometerHtdataServiceImpl implements IPsdcThermometerHtdataS
PsdcDevicePowerHdata96 hdata96 = psdcDevicePowerHdata96Mapper.queryById(userId, deviceId, sdf2.format(new Date())); PsdcDevicePowerHdata96 hdata96 = psdcDevicePowerHdata96Mapper.queryById(userId, deviceId, sdf2.format(new Date()));
PsdcDevicePowerRes rtdata = psdcElectricRtdataMapper.queryById(deviceId, sdf.format(new Date())); PsdcDevicePowerRes rtdata = psdcElectricRtdataMapper.queryById(deviceId, sdf.format(new Date()));
if (null != hdata96 && null != rtdata){ if (null != hdata96 && null != rtdata) {
rtdata.setTodayUsePowers(hdata96); rtdata.setTodayUsePowers(hdata96);
return rtdata; return rtdata;
} else { } else {
@ -123,7 +123,7 @@ public class PsdcThermometerHtdataServiceImpl implements IPsdcThermometerHtdataS
PsdcThermometerDataRes dataRes = psdcThermometerRtdataMapper.queryById(deviceId, sdf.format(date)); PsdcThermometerDataRes dataRes = psdcThermometerRtdataMapper.queryById(deviceId, sdf.format(date));
List<PsdcThermometerHtdata> htdata = psdcThermometerHtdataMapper.selTodayThermometer(deviceId, tb, te); List<PsdcThermometerHtdata> htdata = psdcThermometerHtdataMapper.selTodayThermometer(deviceId, tb, te);
if (null == dataRes || null == htdata){ if (null == dataRes || null == htdata) {
return null; return null;
} }
@ -134,33 +134,46 @@ public class PsdcThermometerHtdataServiceImpl implements IPsdcThermometerHtdataS
// 循环遍历今天历史数据对象集合 // 循环遍历今天历史数据对象集合
for (PsdcThermometerHtdata h : htdata){ for (PsdcThermometerHtdata h : htdata) {
if (null != h.getThermometerValue()){ if (null != h.getThermometerValue()) {
listTemp.add(h.getThermometerValue()); listTemp.add(h.getThermometerValue());
} }
if (null != h.getThermometerValueIn()){ if (null != h.getThermometerValueIn()) {
listIn.add(h.getThermometerValueIn()); listIn.add(h.getThermometerValueIn());
} }
if (null != h.getThermometerValueOut()){ if (null != h.getThermometerValueOut()) {
listOut.add(h.getThermometerValueOut()); listOut.add(h.getThermometerValueOut());
} }
String t = h.getUpdateTime().split(" ")[1].substring(0,5); String t = h.getUpdateTime().split(" ")[1].substring(0, 5);
times.add(t); times.add(t);
} }
map.put("deviceId", dataRes.getDeviceId()); map.put("deviceId", dataRes.getDeviceId());
map.put("deviceName", dataRes.getDeviceName()); map.put("deviceName", dataRes.getDeviceName());
map.put("deviceTemp", dataRes.getThermometerValue());
map.put("tempIn", listIn); map.put("tempIn", listIn);
map.put("tempOut", listOut); map.put("tempOut", listOut);
map.put("temps", listTemp); map.put("temps", listTemp);
map.put("times", times); map.put("times", times);
Map<String, Object> map2 = new HashMap();
List<PsdcThermometerDataRes> dataRes1 = psdcThermometerRtdataMapper.selWenDu(SecurityUtils.getUserId(), 16);
ArrayList<Map> ary = new ArrayList<>();
// 循环遍历温度实时对象集合并
for (PsdcThermometerDataRes temp : dataRes1) {
Map<String, Object> map3 = new HashMap();
map3.put("deviceId", temp.getDeviceId());
map3.put("deviceName", temp.getDeviceName());
map3.put("deviceTemp", temp.getThermometerValue());
ary.add(map3);
}
map2.put("realTemp", ary);
map2.put("tempList", map);
return map; return map2;
} }
/** /**
* 查询电磁锅炉进水出水温度 * 查询电磁锅炉进水出水温度
*
* @return * @return
*/ */
@Override @Override
@ -174,17 +187,17 @@ public class PsdcThermometerHtdataServiceImpl implements IPsdcThermometerHtdataS
List<String> times = new ArrayList(); // 时间轴 List<String> times = new ArrayList(); // 时间轴
// 循环遍历今天历史数据对象集合 // 循环遍历今天历史数据对象集合
List<PsdcThermometerHtdata> htdata = psdcThermometerHtdataMapper.selTodayThermometer(deviceId, tb, te); List<PsdcThermometerHtdata> htdata = psdcThermometerHtdataMapper.selTodayThermometer(deviceId, tb, te);
for (PsdcThermometerHtdata h : htdata){ for (PsdcThermometerHtdata h : htdata) {
if (null != h.getThermometerValueIn()){ if (null != h.getThermometerValueIn()) {
listIn.add(h.getThermometerValueIn()); listIn.add(h.getThermometerValueIn());
} }
if (null != h.getThermometerValueOut()){ if (null != h.getThermometerValueOut()) {
listOut.add(h.getThermometerValueOut()); listOut.add(h.getThermometerValueOut());
} }
if (null != h.getThermometerValue()){ if (null != h.getThermometerValue()) {
listTemps.add(h.getThermometerValue()); listTemps.add(h.getThermometerValue());
} }
String t = h.getUpdateTime().split(" ")[1].substring(0,5); String t = h.getUpdateTime().split(" ")[1].substring(0, 5);
times.add(t); times.add(t);
} }
AjaxResult ajax = AjaxResult.success().put("tempIn", listIn).put("tempOut", listOut).put("temps", listTemps).put("times", times); AjaxResult ajax = AjaxResult.success().put("tempIn", listIn).put("tempOut", listOut).put("temps", listTemps).put("times", times);

@ -78,7 +78,7 @@
<if test="userId != null and userId != ''"> <if test="userId != null and userId != ''">
And user_id = #{userId} And user_id = #{userId}
</if> </if>
<if test="parentId != null and parentId != ''"> <if test="parentId != null ">
And parent_id = #{parentId} And parent_id = #{parentId}
</if> </if>
</where> </where>

@ -65,7 +65,7 @@
<if test="upDate != null and upDate != ''"> <if test="upDate != null and upDate != ''">
And DATE_FORMAT(per.update_time,'%Y-%m-%d') = #{upDate} And DATE_FORMAT(per.update_time,'%Y-%m-%d') = #{upDate}
</if> </if>
<if test="upDate != null and upDate != ''"> <if test="upDate != null and upDate != '' and electricId != 13">
And DATE_FORMAT(ptr.update_time,'%Y-%m-%d') = #{upDate} And DATE_FORMAT(ptr.update_time,'%Y-%m-%d') = #{upDate}
</if> </if>
</select> </select>

@ -35,9 +35,10 @@
</select> </select>
<select id="selWenDu" resultMap="PsdcThermometerRtdataMap2"> <select id="selWenDu" resultMap="PsdcThermometerRtdataMap2">
Select pd.device_id, pd.device_name, ptr.thermometer_value From psdc_thermometer_rtdata ptr Select pd.device_id, pd.device_name, ptr.thermometer_value
From psdc_thermometer_rtdata ptr
Left Join psdc_device pd On pd.device_id = ptr.device_id Left Join psdc_device pd On pd.device_id = ptr.device_id
Where device_type = ${devType} Where pd.user_id = ${userId} And pd.parent_id = ${parentId}
</select> </select>
<!--分页查询指定行数据--> <!--分页查询指定行数据-->

@ -13,7 +13,6 @@ import com.psdc.service.IPsdcDeviceService;
import com.psdc.service.ISysUserService; import com.psdc.service.ISysUserService;
import com.psdc.utils.SecurityUtils; import com.psdc.utils.SecurityUtils;
import com.psdc.utils.poi.ExcelUtil; import com.psdc.utils.poi.ExcelUtil;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFRow; import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet; import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.apache.poi.xssf.usermodel.XSSFWorkbook;
@ -26,7 +25,6 @@ import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.BufferedOutputStream; import java.io.BufferedOutputStream;
import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.util.*; import java.util.*;
@ -39,7 +37,7 @@ import java.util.*;
* @Version 1.0 * @Version 1.0
*/ */
@RestController @RestController
@RequestMapping("/manager/device") @RequestMapping("/system/device/index")
public class PsdcDeviceController extends BaseController { public class PsdcDeviceController extends BaseController {
@Autowired @Autowired
@ -49,7 +47,7 @@ public class PsdcDeviceController extends BaseController {
ISysUserService sysUserService; ISysUserService sysUserService;
@PreAuthorize("@ss.hasPermi('manager:device:list')") @PreAuthorize("@ss.hasPermi('system:device:list')")
@Log(title = "设备管理", businessType = BusinessType.INSERT) @Log(title = "设备管理", businessType = BusinessType.INSERT)
@PostMapping @PostMapping
public AjaxResult add(@Validated @RequestBody PsdcDevice pd) { public AjaxResult add(@Validated @RequestBody PsdcDevice pd) {
@ -60,7 +58,7 @@ public class PsdcDeviceController extends BaseController {
} }
@PreAuthorize("@ss.hasPermi('manager:device:list')") @PreAuthorize("@ss.hasPermi('system:device:list')")
@Log(title = "设备管理", businessType = BusinessType.UPDATE) @Log(title = "设备管理", businessType = BusinessType.UPDATE)
@PutMapping @PutMapping
public AjaxResult edit(@Validated @RequestBody PsdcDevice pd) { public AjaxResult edit(@Validated @RequestBody PsdcDevice pd) {
@ -70,7 +68,7 @@ public class PsdcDeviceController extends BaseController {
return toAjax(psdcDeviceService.update(pd)); return toAjax(psdcDeviceService.update(pd));
} }
@PreAuthorize("@ss.hasPermi('manager:device:list')") @PreAuthorize("@ss.hasPermi('system:device:list')")
@Log(title = "设备管理", businessType = BusinessType.DELETE) @Log(title = "设备管理", businessType = BusinessType.DELETE)
@DeleteMapping @DeleteMapping
public AjaxResult remove(@Validated @RequestBody Long[] deviceIds) { public AjaxResult remove(@Validated @RequestBody Long[] deviceIds) {
@ -78,7 +76,7 @@ public class PsdcDeviceController extends BaseController {
} }
@PreAuthorize("@ss.hasPermi('manager:device:list')") @PreAuthorize("@ss.hasPermi('system:device:list')")
@RequestMapping(value = "/selusers", method = RequestMethod.GET) @RequestMapping(value = "/selusers", method = RequestMethod.GET)
public AjaxResult selAllUsers() { public AjaxResult selAllUsers() {
List<Map> maps = new ArrayList<>(); List<Map> maps = new ArrayList<>();
@ -92,7 +90,7 @@ public class PsdcDeviceController extends BaseController {
return AjaxResult.success("用户下拉列表", maps); return AjaxResult.success("用户下拉列表", maps);
} }
@PreAuthorize("@ss.hasPermi('manager:device:list')") @PreAuthorize("@ss.hasPermi('system:device:list')")
@RequestMapping(value = "/devicesList", method = RequestMethod.POST) @RequestMapping(value = "/devicesList", method = RequestMethod.POST)
public TableDataInfo controlLogList(@RequestBody JSONObject jsonObject) { public TableDataInfo controlLogList(@RequestBody JSONObject jsonObject) {
// PageMethod.startPage(jsonObject.getInteger("pageNum"),jsonObject.getInteger("pageSize")); // PageMethod.startPage(jsonObject.getInteger("pageNum"),jsonObject.getInteger("pageSize"));
@ -105,7 +103,7 @@ public class PsdcDeviceController extends BaseController {
/** /**
excel文件的下载 excel文件的下载
*/ */
@PreAuthorize("@ss.hasPermi('manager:device:list')") @PreAuthorize("@ss.hasPermi('system:device:list')")
@Log(title = "设备管理", businessType = BusinessType.EXPORT) @Log(title = "设备管理", businessType = BusinessType.EXPORT)
@RequestMapping(value = "/daochuDevs", method = RequestMethod.POST) @RequestMapping(value = "/daochuDevs", method = RequestMethod.POST)
public void daochuDevDta(HttpServletResponse response, @RequestBody PsdcDevice pd) { public void daochuDevDta(HttpServletResponse response, @RequestBody PsdcDevice pd) {
@ -121,7 +119,7 @@ public class PsdcDeviceController extends BaseController {
* 下载设备信息模板 * 下载设备信息模板
* @param response * @param response
*/ */
@PreAuthorize("@ss.hasPermi('manager:device:list')") @PreAuthorize("@ss.hasPermi('system:device:list')")
@Log(title = "设备管理", businessType = BusinessType.EXPORT) @Log(title = "设备管理", businessType = BusinessType.EXPORT)
@RequestMapping(value = "/downloadDevTemplate", method = RequestMethod.GET) @RequestMapping(value = "/downloadDevTemplate", method = RequestMethod.GET)
public void downloadTemplate(HttpServletResponse response) { public void downloadTemplate(HttpServletResponse response) {
@ -162,7 +160,7 @@ public class PsdcDeviceController extends BaseController {
excel文件的读取 excel文件的读取
*/ */
@RequestMapping("/daoruDevData") @RequestMapping("/daoruDevData")
@PreAuthorize("@ss.hasPermi('manager:device:list')") @PreAuthorize("@ss.hasPermi('system:device:list')")
@Log(title = "设备管理", businessType = BusinessType.IMPORT) @Log(title = "设备管理", businessType = BusinessType.IMPORT)
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public AjaxResult daoruDevData(@RequestPart("file") MultipartFile file) { public AjaxResult daoruDevData(@RequestPart("file") MultipartFile file) {

@ -42,11 +42,28 @@ public class TotalElectricMeterController {
@RequestMapping(value = "/selMydevices", method = RequestMethod.GET) @RequestMapping(value = "/selMydevices", method = RequestMethod.GET)
public AjaxResult selMydevices() { public AjaxResult selMydevices() {
List<Map> maps = new ArrayList<>(); List<Map> maps = new ArrayList<>();
List<PsdcDevice> list = psdcDeviceService.queryByUserId(); List<PsdcDevice> list = psdcDeviceService.queryByUserId(0);
for (PsdcDevice dd : list){ for (PsdcDevice dd : list){
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
map.put("label", dd.getDeviceName()); map.put("modelName", dd.getDeviceModel());
map.put("value", dd.getDeviceId()); List<Map> maps2 = new ArrayList<>();
List<PsdcDevice> list2 = psdcDeviceService.queryByUserId(dd.getDeviceId());
if (list2.size() > 0){
for (PsdcDevice dev : list2){
Map<String, Object> map2 = new HashMap<>();
map2.put("deviceId", dev.getDeviceId());
map2.put("deviceName", dev.getDeviceName());
maps2.add(map2);
}
} else {
PsdcDevice dev = psdcDeviceService.queryById(dd.getDeviceId());
Map<String, Object> map2 = new HashMap<>();
map2.put("deviceId", dev.getDeviceId());
map2.put("deviceName", dev.getDeviceName());
maps2.add(map2);
}
map.put("children", maps2);
maps.add(map); maps.add(map);
} }
return AjaxResult.success("用户所属设备列表", maps); return AjaxResult.success("用户所属设备列表", maps);

Loading…
Cancel
Save