Commit 28465f81 authored by 高建强's avatar 高建强

item:稳压泵启停状态图接口新增

parent 2e33a4d3
...@@ -85,6 +85,18 @@ public class DateUtils { ...@@ -85,6 +85,18 @@ public class DateUtils {
} }
return returnValue; return returnValue;
} }
/**
* 将字符换转换为日期
* @param date
* @param pattern
* @return
* @throws ParseException
*/
public static Date convertStrToDate(String date, String pattern) throws ParseException {
SimpleDateFormat formatter = new SimpleDateFormat(pattern);
return formatter.parse(date);
}
/** /**
* 获取当前时间任意 * 获取当前时间任意
...@@ -956,4 +968,26 @@ public class DateUtils { ...@@ -956,4 +968,26 @@ public class DateUtils {
return now; return now;
} }
public static List<String> getTimeStrListByStartAndEnd(String startTime, String endTime, String pattern) {
try {
List<String> list = new ArrayList<>();
Date startDate = convertStrToDate(startTime, DATE_TIME_PATTERN);
Date endDate = convertStrToDate(endTime, DATE_TIME_PATTERN);
list.add(convertDateToString(startDate, pattern));
Date date = startDate;
while (true) {
date = dateAddMinutes(date, 1);
if (dateCompare(endDate, date) == 1) {
list.add(convertDateToString(date, pattern));
} else {
list.add(convertDateToString(endDate, pattern));
break;
}
}
return list;
} catch (ParseException e) {
throw new RuntimeException(e);
}
}
} }
...@@ -19,19 +19,14 @@ import org.springframework.web.bind.annotation.RequestMapping; ...@@ -19,19 +19,14 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import org.typroject.tyboot.core.foundation.enumeration.UserType; import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.foundation.utils.DateTimeUtil; import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.restful.doc.TycloudOperation; import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.utils.ResponseModel; import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.ZoneId;
import java.util.*; import java.util.*;
import static org.typroject.tyboot.core.foundation.utils.DateTimeUtil.ISO8601_DATE_HOUR_MIN_SEC;
/** /**
* *
* 四横八纵应急模块接口 * 四横八纵应急模块接口
...@@ -583,4 +578,23 @@ public class EmergencyController extends AbstractBaseController { ...@@ -583,4 +578,23 @@ public class EmergencyController extends AbstractBaseController {
return CommonResponseUtil.success(iEmergencyService.getStockEquipStatistics()); return CommonResponseUtil.success(iEmergencyService.getStockEquipStatistics());
} }
@PersonIdentify
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/getPressurePumpStatusChart")
@ApiOperation(httpMethod = "GET", value = "四横八纵-稳压泵启停状态图", notes = "四横八纵-稳压泵启停状态图")
public ResponseModel getPressurePumpStatusChart(@RequestParam String equipmentCode, @RequestParam String startTime, @RequestParam String endTime,
@RequestParam(required = false) String fieldKey, @RequestParam(required = false) String bizOrgCode) {
if(StringUtils.isEmpty(bizOrgCode)) {
ReginParams reginParams = getSelectedOrgInfo();
ReginParams.PersonIdentity personIdentity = reginParams.getPersonIdentity();
if (!ValidationUtil.isEmpty(personIdentity)) {
bizOrgCode = personIdentity.getBizOrgCode();
if (bizOrgCode == null) {
return CommonResponseUtil.success(Collections.EMPTY_MAP);
}
}
}
return CommonResponseUtil.success(iEmergencyService.getPressurePumpStatusChart(equipmentCode, startTime, endTime, fieldKey, bizOrgCode, getAppKey(), getProduct(), getToken()));
}
} }
...@@ -227,6 +227,8 @@ public interface EquipmentSpecificMapper extends BaseMapper<EquipmentSpecific> { ...@@ -227,6 +227,8 @@ public interface EquipmentSpecificMapper extends BaseMapper<EquipmentSpecific> {
List<Map<String, Object>> getFirePumpInfo(@Param("list") String[] strings); List<Map<String, Object>> getFirePumpInfo(@Param("list") String[] strings);
List<Map<String, Object>> getListByEquipmentCode(@Param("list") String[] strings, @Param("bizOrgCode") String bizOrgCode);
Integer getAllEquipNum(@Param("bizOrgCode") String bizOrgCode); Integer getAllEquipNum(@Param("bizOrgCode") String bizOrgCode);
List<Map<String, Object>> normalIndexInfoList(@Param("startDate") String startDate, @Param("endDate") String endDate); List<Map<String, Object>> normalIndexInfoList(@Param("startDate") String startDate, @Param("endDate") String endDate);
......
...@@ -53,4 +53,6 @@ public interface IEmergencyService { ...@@ -53,4 +53,6 @@ public interface IEmergencyService {
List<Map<String, String>> getEquipExpiryList(Integer expiryDayNum); List<Map<String, String>> getEquipExpiryList(Integer expiryDayNum);
Map<String, Integer> getStockEquipStatistics(); Map<String, Integer> getStockEquipStatistics();
Map<String, Object> getPressurePumpStatusChart(String equipmentCode, String startTime, String endTime, String fieldKey, String bizOrgCode, String appKey, String product, String token);
} }
...@@ -229,6 +229,13 @@ public interface IEquipmentSpecificSerivce extends IService<EquipmentSpecific> { ...@@ -229,6 +229,13 @@ public interface IEquipmentSpecificSerivce extends IService<EquipmentSpecific> {
List<Map<String, Object>> getListByEquipmentCode(String code); List<Map<String, Object>> getListByEquipmentCode(String code);
/** /**
* 根据装备分类code获取装备列表,id 升序
* @param code 装备分类逗号隔开
* @return 装备list
*/
List<Map<String, Object>> getListByEquipmentCode(String code, String bizOrgCode);
/**
* 根据装备id获取物联日志 * 根据装备id获取物联日志
* @param iotCode code * @param iotCode code
* @param entity 日志 * @param entity 日志
......
package com.yeejoin.equipmanage.service.impl; package com.yeejoin.equipmanage.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.equipmanage.common.enums.IndexStatusEnum; import com.yeejoin.equipmanage.common.enums.IndexStatusEnum;
import com.yeejoin.equipmanage.common.utils.DateUtils; import com.yeejoin.equipmanage.common.utils.DateUtils;
import com.yeejoin.equipmanage.common.utils.StringUtil; import com.yeejoin.equipmanage.common.utils.StringUtil;
import com.yeejoin.equipmanage.common.utils.UnitTransformUtil; import com.yeejoin.equipmanage.common.utils.UnitTransformUtil;
import com.yeejoin.equipmanage.fegin.IotFeign;
import com.yeejoin.equipmanage.mapper.EmergencyMapper; import com.yeejoin.equipmanage.mapper.EmergencyMapper;
import com.yeejoin.equipmanage.service.IEmergencyService; import com.yeejoin.equipmanage.service.IEmergencyService;
import com.yeejoin.equipmanage.service.IEquipmentSpecificSerivce;
import org.apache.commons.compress.utils.Lists; import org.apache.commons.compress.utils.Lists;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
import java.util.stream.Collectors;
import static com.yeejoin.equipmanage.common.utils.DateUtils.getFirstDayOfMonth;
/** /**
* *
...@@ -31,6 +33,12 @@ public class EmergencyServiceImpl implements IEmergencyService { ...@@ -31,6 +33,12 @@ public class EmergencyServiceImpl implements IEmergencyService {
@Autowired @Autowired
private EmergencyMapper emergencyMapper; private EmergencyMapper emergencyMapper;
@Autowired
private IEquipmentSpecificSerivce equipmentSpecificSerivce;
@Autowired
private IotFeign iotFeign;
@Override @Override
public List<Map<String, Object>> getSystemState(String bizOrgCode) { public List<Map<String, Object>> getSystemState(String bizOrgCode) {
List<Map<String, Object>> list = emergencyMapper.getSystemState(bizOrgCode); List<Map<String, Object>> list = emergencyMapper.getSystemState(bizOrgCode);
...@@ -199,4 +207,62 @@ public class EmergencyServiceImpl implements IEmergencyService { ...@@ -199,4 +207,62 @@ public class EmergencyServiceImpl implements IEmergencyService {
return emergencyMapper.getStockEquipStatistics(); return emergencyMapper.getStockEquipStatistics();
} }
@Override
public Map<String, Object> getPressurePumpStatusChart(String equipmentCode, String startTime, String endTime, String fieldKey, String bizOrgCode, String appKey, String product, String token) {
Map<String, Object> map = new HashMap<>();
List<String> timeList = DateUtils.getTimeStrListByStartAndEnd(startTime, endTime, "MM-dd HH:mm");
// 获取稳压泵
List<Map<String, Object>> list = equipmentSpecificSerivce.getListByEquipmentCode(equipmentCode, bizOrgCode);
if (!CollectionUtils.isEmpty(list)) {
List<Map<String, Object>> yData = new ArrayList<>();
list.forEach(x -> {
Map<String, Object> yMap = new HashMap<>();
List<Integer> yList = new ArrayList<>();
String name = x.get("name").toString();
yMap.put("name", name);
String iotCode = x.get("iotCode").toString();
String prefix = null;
String suffix = null;
if (iotCode.length() > 8) {
prefix = iotCode.substring(0, 8);
suffix = iotCode.substring(8);
} else {
throw new BadRequest("装备物联编码错误,请确认!");
}
ResponseModel responseModel = null;
try {
responseModel = iotFeign.selectList(appKey, product, token, startTime, endTime, prefix, suffix, fieldKey);
} catch (Exception e) {
e.printStackTrace();
}
if (200 == responseModel.getStatus()) {
String json = JSON.toJSONString(responseModel.getResult());
List<Map<String, String>> dataList = (List<Map<String, String>>) JSONArray.parse(json);
if (!CollectionUtils.isEmpty(dataList)) {
Collections.reverse(dataList);
Map<String, List<Map<String, String>>> dataMap = dataList.stream().collect(Collectors.groupingBy(e -> e.get("time").substring(5, 16).replace("T", " ")));
timeList.forEach(t -> {
List<Map<String, String>> data = dataMap.get(t);
if (!CollectionUtils.isEmpty(data)) {
List<Map<String, String>> yDataList = dataMap.get(t).stream().filter(o -> "true".equals(o.get(fieldKey).toString())).collect(Collectors.toList());
yList.add(CollectionUtils.isEmpty(yDataList) ? 0 : 1);
} else {
yList.add(0);
}
});
} else {
timeList.forEach(t -> {
yList.add(0);
});
}
}
yMap.put("data", yList);
yData.add(yMap);
});
map.put("xData", timeList);
map.put("yData", yData);
}
return map;
}
} }
...@@ -1787,6 +1787,16 @@ public class EquipmentSpecificSerivceImpl extends ServiceImpl<EquipmentSpecificM ...@@ -1787,6 +1787,16 @@ public class EquipmentSpecificSerivceImpl extends ServiceImpl<EquipmentSpecificM
} }
@Override @Override
public List<Map<String, Object>> getListByEquipmentCode(String code, String bizOrgCode) {
List<Map<String, Object>> list = new ArrayList<>();
if (StringUtil.isNotEmpty(code)) {
String[] strings = code.split(",");
list = equipmentSpecificMapper.getListByEquipmentCode(strings, bizOrgCode);
}
return list;
}
@Override
public List<IotIndexInfoVo> getIndexInfoList(String iotCode, ResponseModel entity, Integer isTrend, String fieldKey) { public List<IotIndexInfoVo> getIndexInfoList(String iotCode, ResponseModel entity, Integer isTrend, String fieldKey) {
List<IotIndexInfoVo> infoVoList = new ArrayList<>(); List<IotIndexInfoVo> infoVoList = new ArrayList<>();
String json = JSON.toJSONString(entity.getResult()); String json = JSON.toJSONString(entity.getResult());
......
...@@ -1631,6 +1631,29 @@ ...@@ -1631,6 +1631,29 @@
</where> </where>
ORDER BY realtiemIotIndexUpdateDate DESC ORDER BY realtiemIotIndexUpdateDate DESC
</select> </select>
<select id="getListByEquipmentCode" resultType="Map">
SELECT
wes.id,
wes.name,
wes.code,
wes.equipment_code equipmentCode,
wes.realtime_iot_index_name realtimeIotIndexName,
wes.realtime_iot_index_key realtimeIotIndexKey,
wes.iot_code iotCode
FROM
wl_equipment_specific wes
<where>
<if test="list != null and list.length > 0">
<foreach collection="list" item="item" index="index" open="(" close=")" separator="OR">
wes.equipment_code LIKE <![CDATA[CONCAT(#{item},'%')]]>
</foreach>
</if>
<if test="bizOrgCode != null and bizOrgCode != ''">
AND wes.biz_org_code LIKE concat(#{bizOrgCode}, '%')
</if>
</where>
ORDER BY wes.id
</select>
<select id="getAllEquipNum" resultType="java.lang.Integer"> <select id="getAllEquipNum" resultType="java.lang.Integer">
select count(*) from wl_equipment_specific select count(*) from wl_equipment_specific
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment