From 138037e3cd4f99575e74f2622959a431da5226c6 Mon Sep 17 00:00:00 2001 From: XMnhwj_BackTechnologyDevelopment <3512363680@qq.com> Date: Mon, 15 May 2023 10:19:33 +0800 Subject: [PATCH] =?UTF-8?q?2023-05-15=2010:18:26=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E5=AE=8C=E5=96=84=E9=A6=96=E9=A1=B5=E5=A4=A7=E5=B1=8F=E3=80=81?= =?UTF-8?q?=E8=83=BD=E6=BA=90=E7=9B=91=E6=B5=8B=E7=9A=84=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mapper/PsdcThermometerRtdataMapper.java | 3 +- .../com/psdc/service/IPsdcDeviceService.java | 2 +- .../service/impl/PsdcDeviceServiceImpl.java | 4 +- .../PsdcThermometerHtdataServiceImpl.java | 55 ++++++++++++------- .../mapper/business/PsdcDeviceMapper.xml | 2 +- .../business/PsdcElectricRtdataMapper.xml | 2 +- .../business/PsdcThermometerRtdataMapper.xml | 5 +- .../manager/PsdcDeviceController.java | 20 +++---- .../monitor/TotalElectricMeterController.java | 23 +++++++- 9 files changed, 73 insertions(+), 43 deletions(-) diff --git a/psdc-business/src/main/java/com/psdc/mapper/PsdcThermometerRtdataMapper.java b/psdc-business/src/main/java/com/psdc/mapper/PsdcThermometerRtdataMapper.java index 582518f..32f71c4 100644 --- a/psdc-business/src/main/java/com/psdc/mapper/PsdcThermometerRtdataMapper.java +++ b/psdc-business/src/main/java/com/psdc/mapper/PsdcThermometerRtdataMapper.java @@ -26,7 +26,8 @@ public interface PsdcThermometerRtdataMapper{ PsdcThermometerDataRes queryById(@Param("thermometerRtdataId") Integer thermometerRtdataId, @Param("today") String today); - List selWenDu(@Param("devType") Integer devType); + List selWenDu(@Param("userId") Long userId, + @Param("parentId") Integer parentId); /** * 分页查询指定行数据 diff --git a/psdc-business/src/main/java/com/psdc/service/IPsdcDeviceService.java b/psdc-business/src/main/java/com/psdc/service/IPsdcDeviceService.java index 322f809..76aa545 100644 --- a/psdc-business/src/main/java/com/psdc/service/IPsdcDeviceService.java +++ b/psdc-business/src/main/java/com/psdc/service/IPsdcDeviceService.java @@ -21,7 +21,7 @@ public interface IPsdcDeviceService { * 根据用户id查询设备列表 * @return */ - List queryByUserId(); + List queryByUserId(Integer parent); /** * 查询所有设备状态 diff --git a/psdc-business/src/main/java/com/psdc/service/impl/PsdcDeviceServiceImpl.java b/psdc-business/src/main/java/com/psdc/service/impl/PsdcDeviceServiceImpl.java index 7bed810..0ee25ca 100644 --- a/psdc-business/src/main/java/com/psdc/service/impl/PsdcDeviceServiceImpl.java +++ b/psdc-business/src/main/java/com/psdc/service/impl/PsdcDeviceServiceImpl.java @@ -51,8 +51,8 @@ public class PsdcDeviceServiceImpl implements IPsdcDeviceService { * 根据用户id查询设备列表 * @return 设备列表 */ - public List queryByUserId() { - return psdcDeviceMapper.queryByUserId(SecurityUtils.getUserId(), 0); + public List queryByUserId(Integer parent) { + return psdcDeviceMapper.queryByUserId(SecurityUtils.getUserId(), parent); } public List queryDeviceStatus() { diff --git a/psdc-business/src/main/java/com/psdc/service/impl/PsdcThermometerHtdataServiceImpl.java b/psdc-business/src/main/java/com/psdc/service/impl/PsdcThermometerHtdataServiceImpl.java index bfb69e9..c844f1d 100644 --- a/psdc-business/src/main/java/com/psdc/service/impl/PsdcThermometerHtdataServiceImpl.java +++ b/psdc-business/src/main/java/com/psdc/service/impl/PsdcThermometerHtdataServiceImpl.java @@ -53,7 +53,7 @@ public class PsdcThermometerHtdataServiceImpl implements IPsdcThermometerHtdataS 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)); @@ -64,18 +64,18 @@ public class PsdcThermometerHtdataServiceImpl implements IPsdcThermometerHtdataS // 循环遍历今天历史数据对象集合 List htdata = psdcThermometerHtdataMapper.selTodayThermometer(d, tb, te); - for (PsdcThermometerHtdata h : htdata){ - if (null != h.getThermometerValue()){ + for (PsdcThermometerHtdata h : htdata) { + if (null != h.getThermometerValue()) { listTemp.add(h.getThermometerValue()); } - if (null != h.getThermometerValueIn()){ + if (null != h.getThermometerValueIn()) { listIn.add(h.getThermometerValueIn()); } - if (null != h.getThermometerValueOut()){ + if (null != 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); } @@ -95,7 +95,7 @@ public class PsdcThermometerHtdataServiceImpl implements IPsdcThermometerHtdataS @Override public AjaxResult sel8WnDu() { - List dataResList = psdcThermometerRtdataMapper.selWenDu(1); + List dataResList = psdcThermometerRtdataMapper.selWenDu(SecurityUtils.getUserId(), 16); return AjaxResult.success(dataResList); } @@ -105,7 +105,7 @@ public class PsdcThermometerHtdataServiceImpl implements IPsdcThermometerHtdataS PsdcDevicePowerHdata96 hdata96 = psdcDevicePowerHdata96Mapper.queryById(userId, deviceId, sdf2.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); return rtdata; } else { @@ -123,7 +123,7 @@ public class PsdcThermometerHtdataServiceImpl implements IPsdcThermometerHtdataS PsdcThermometerDataRes dataRes = psdcThermometerRtdataMapper.queryById(deviceId, sdf.format(date)); List htdata = psdcThermometerHtdataMapper.selTodayThermometer(deviceId, tb, te); - if (null == dataRes || null == htdata){ + if (null == dataRes || null == htdata) { return null; } @@ -134,33 +134,46 @@ public class PsdcThermometerHtdataServiceImpl implements IPsdcThermometerHtdataS // 循环遍历今天历史数据对象集合 - for (PsdcThermometerHtdata h : htdata){ - if (null != h.getThermometerValue()){ + for (PsdcThermometerHtdata h : htdata) { + if (null != h.getThermometerValue()) { listTemp.add(h.getThermometerValue()); } - if (null != h.getThermometerValueIn()){ + if (null != h.getThermometerValueIn()) { listIn.add(h.getThermometerValueIn()); } - if (null != h.getThermometerValueOut()){ + if (null != 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); } map.put("deviceId", dataRes.getDeviceId()); map.put("deviceName", dataRes.getDeviceName()); - map.put("deviceTemp", dataRes.getThermometerValue()); map.put("tempIn", listIn); map.put("tempOut", listOut); map.put("temps", listTemp); map.put("times", times); + Map map2 = new HashMap(); + List dataRes1 = psdcThermometerRtdataMapper.selWenDu(SecurityUtils.getUserId(), 16); + ArrayList ary = new ArrayList<>(); + // 循环遍历温度实时对象集合并 + for (PsdcThermometerDataRes temp : dataRes1) { + Map 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 */ @Override @@ -174,17 +187,17 @@ public class PsdcThermometerHtdataServiceImpl implements IPsdcThermometerHtdataS List times = new ArrayList(); // 时间轴 // 循环遍历今天历史数据对象集合 List htdata = psdcThermometerHtdataMapper.selTodayThermometer(deviceId, tb, te); - for (PsdcThermometerHtdata h : htdata){ - if (null != h.getThermometerValueIn()){ + for (PsdcThermometerHtdata h : htdata) { + if (null != h.getThermometerValueIn()) { listIn.add(h.getThermometerValueIn()); } - if (null != h.getThermometerValueOut()){ + if (null != h.getThermometerValueOut()) { listOut.add(h.getThermometerValueOut()); } - if (null != h.getThermometerValue()){ + if (null != 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); } AjaxResult ajax = AjaxResult.success().put("tempIn", listIn).put("tempOut", listOut).put("temps", listTemps).put("times", times); diff --git a/psdc-business/src/main/resources/mapper/business/PsdcDeviceMapper.xml b/psdc-business/src/main/resources/mapper/business/PsdcDeviceMapper.xml index 3b1510e..c61ab24 100644 --- a/psdc-business/src/main/resources/mapper/business/PsdcDeviceMapper.xml +++ b/psdc-business/src/main/resources/mapper/business/PsdcDeviceMapper.xml @@ -78,7 +78,7 @@ And user_id = #{userId} - + And parent_id = #{parentId} diff --git a/psdc-business/src/main/resources/mapper/business/PsdcElectricRtdataMapper.xml b/psdc-business/src/main/resources/mapper/business/PsdcElectricRtdataMapper.xml index 9ff0c36..896fdba 100644 --- a/psdc-business/src/main/resources/mapper/business/PsdcElectricRtdataMapper.xml +++ b/psdc-business/src/main/resources/mapper/business/PsdcElectricRtdataMapper.xml @@ -65,7 +65,7 @@ And DATE_FORMAT(per.update_time,'%Y-%m-%d') = #{upDate} - + And DATE_FORMAT(ptr.update_time,'%Y-%m-%d') = #{upDate} diff --git a/psdc-business/src/main/resources/mapper/business/PsdcThermometerRtdataMapper.xml b/psdc-business/src/main/resources/mapper/business/PsdcThermometerRtdataMapper.xml index e32493c..9ea382a 100644 --- a/psdc-business/src/main/resources/mapper/business/PsdcThermometerRtdataMapper.xml +++ b/psdc-business/src/main/resources/mapper/business/PsdcThermometerRtdataMapper.xml @@ -35,9 +35,10 @@ diff --git a/psdc-web/src/main/java/com/psdc/controller/manager/PsdcDeviceController.java b/psdc-web/src/main/java/com/psdc/controller/manager/PsdcDeviceController.java index 45cdd03..7e9c322 100644 --- a/psdc-web/src/main/java/com/psdc/controller/manager/PsdcDeviceController.java +++ b/psdc-web/src/main/java/com/psdc/controller/manager/PsdcDeviceController.java @@ -13,7 +13,6 @@ import com.psdc.service.IPsdcDeviceService; import com.psdc.service.ISysUserService; import com.psdc.utils.SecurityUtils; 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.XSSFSheet; import org.apache.poi.xssf.usermodel.XSSFWorkbook; @@ -26,7 +25,6 @@ import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletResponse; import java.io.BufferedOutputStream; -import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.*; @@ -39,7 +37,7 @@ import java.util.*; * @Version 1.0 */ @RestController -@RequestMapping("/manager/device") +@RequestMapping("/system/device/index") public class PsdcDeviceController extends BaseController { @Autowired @@ -49,7 +47,7 @@ public class PsdcDeviceController extends BaseController { ISysUserService sysUserService; - @PreAuthorize("@ss.hasPermi('manager:device:list')") + @PreAuthorize("@ss.hasPermi('system:device:list')") @Log(title = "设备管理", businessType = BusinessType.INSERT) @PostMapping 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) @PutMapping public AjaxResult edit(@Validated @RequestBody PsdcDevice pd) { @@ -70,7 +68,7 @@ public class PsdcDeviceController extends BaseController { return toAjax(psdcDeviceService.update(pd)); } - @PreAuthorize("@ss.hasPermi('manager:device:list')") + @PreAuthorize("@ss.hasPermi('system:device:list')") @Log(title = "设备管理", businessType = BusinessType.DELETE) @DeleteMapping 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) public AjaxResult selAllUsers() { List maps = new ArrayList<>(); @@ -92,7 +90,7 @@ public class PsdcDeviceController extends BaseController { return AjaxResult.success("用户下拉列表", maps); } - @PreAuthorize("@ss.hasPermi('manager:device:list')") + @PreAuthorize("@ss.hasPermi('system:device:list')") @RequestMapping(value = "/devicesList", method = RequestMethod.POST) public TableDataInfo controlLogList(@RequestBody JSONObject jsonObject) { // PageMethod.startPage(jsonObject.getInteger("pageNum"),jsonObject.getInteger("pageSize")); @@ -105,7 +103,7 @@ public class PsdcDeviceController extends BaseController { /** excel文件的下载 */ - @PreAuthorize("@ss.hasPermi('manager:device:list')") + @PreAuthorize("@ss.hasPermi('system:device:list')") @Log(title = "设备管理", businessType = BusinessType.EXPORT) @RequestMapping(value = "/daochuDevs", method = RequestMethod.POST) public void daochuDevDta(HttpServletResponse response, @RequestBody PsdcDevice pd) { @@ -121,7 +119,7 @@ public class PsdcDeviceController extends BaseController { * 下载设备信息模板 * @param response */ - @PreAuthorize("@ss.hasPermi('manager:device:list')") + @PreAuthorize("@ss.hasPermi('system:device:list')") @Log(title = "设备管理", businessType = BusinessType.EXPORT) @RequestMapping(value = "/downloadDevTemplate", method = RequestMethod.GET) public void downloadTemplate(HttpServletResponse response) { @@ -162,7 +160,7 @@ public class PsdcDeviceController extends BaseController { excel文件的读取 */ @RequestMapping("/daoruDevData") - @PreAuthorize("@ss.hasPermi('manager:device:list')") + @PreAuthorize("@ss.hasPermi('system:device:list')") @Log(title = "设备管理", businessType = BusinessType.IMPORT) @Transactional(rollbackFor = Exception.class) public AjaxResult daoruDevData(@RequestPart("file") MultipartFile file) { diff --git a/psdc-web/src/main/java/com/psdc/controller/monitor/TotalElectricMeterController.java b/psdc-web/src/main/java/com/psdc/controller/monitor/TotalElectricMeterController.java index dbb823d..307920e 100644 --- a/psdc-web/src/main/java/com/psdc/controller/monitor/TotalElectricMeterController.java +++ b/psdc-web/src/main/java/com/psdc/controller/monitor/TotalElectricMeterController.java @@ -42,11 +42,28 @@ public class TotalElectricMeterController { @RequestMapping(value = "/selMydevices", method = RequestMethod.GET) public AjaxResult selMydevices() { List maps = new ArrayList<>(); - List list = psdcDeviceService.queryByUserId(); + List list = psdcDeviceService.queryByUserId(0); for (PsdcDevice dd : list){ Map map = new HashMap<>(); - map.put("label", dd.getDeviceName()); - map.put("value", dd.getDeviceId()); + map.put("modelName", dd.getDeviceModel()); + List maps2 = new ArrayList<>(); + List list2 = psdcDeviceService.queryByUserId(dd.getDeviceId()); + if (list2.size() > 0){ + for (PsdcDevice dev : list2){ + Map map2 = new HashMap<>(); + map2.put("deviceId", dev.getDeviceId()); + map2.put("deviceName", dev.getDeviceName()); + maps2.add(map2); + } + } else { + PsdcDevice dev = psdcDeviceService.queryById(dd.getDeviceId()); + Map map2 = new HashMap<>(); + map2.put("deviceId", dev.getDeviceId()); + map2.put("deviceName", dev.getDeviceName()); + maps2.add(map2); + } + + map.put("children", maps2); maps.add(map); } return AjaxResult.success("用户所属设备列表", maps);