林颖晨 2 years ago
commit 62a19fb1db
  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,
@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查询设备列表
* @return
*/
List<PsdcDevice> queryByUserId();
List<PsdcDevice> queryByUserId(Integer parent);
/**
* 查询所有设备状态

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

@ -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<PsdcThermometerHtdata> 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<PsdcThermometerDataRes> dataResList = psdcThermometerRtdataMapper.selWenDu(1);
List<PsdcThermometerDataRes> 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<PsdcThermometerHtdata> 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<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
*/
@Override
@ -174,17 +187,17 @@ public class PsdcThermometerHtdataServiceImpl implements IPsdcThermometerHtdataS
List<String> times = new ArrayList(); // 时间轴
// 循环遍历今天历史数据对象集合
List<PsdcThermometerHtdata> 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);

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

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

@ -35,9 +35,10 @@
</select>
<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
Where device_type = ${devType}
Where pd.user_id = ${userId} And pd.parent_id = ${parentId}
</select>
<!--分页查询指定行数据-->

@ -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<Map> 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) {

@ -42,11 +42,28 @@ public class TotalElectricMeterController {
@RequestMapping(value = "/selMydevices", method = RequestMethod.GET)
public AjaxResult selMydevices() {
List<Map> maps = new ArrayList<>();
List<PsdcDevice> list = psdcDeviceService.queryByUserId();
List<PsdcDevice> list = psdcDeviceService.queryByUserId(0);
for (PsdcDevice dd : list){
Map<String, Object> map = new HashMap<>();
map.put("label", dd.getDeviceName());
map.put("value", dd.getDeviceId());
map.put("modelName", dd.getDeviceModel());
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);
}
return AjaxResult.success("用户所属设备列表", maps);

Loading…
Cancel
Save