Commit 086ed059 authored by 高建强's avatar 高建强

item:解决稳压泵统计与分析存在部门层级问题

parent 53845507
...@@ -29,6 +29,7 @@ public enum PressurePumpRelateEnum { ...@@ -29,6 +29,7 @@ public enum PressurePumpRelateEnum {
STOP("0", "停止"), STOP("0", "停止"),
RESET("2", "复位"), RESET("2", "复位"),
CREATED_TIME("createdTime", "物联采集信号创建时间属性"), CREATED_TIME("createdTime", "物联采集信号创建时间属性"),
BIZ_ORG_TYPE_COMPANY("COMPANY", "bizOrgType之公司"),
UN_CLEAN_TIME("false", "未消除"); UN_CLEAN_TIME("false", "未消除");
private final String value; private final String value;
......
...@@ -634,18 +634,8 @@ public class EmergencyController extends AbstractBaseController { ...@@ -634,18 +634,8 @@ public class EmergencyController extends AbstractBaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/getPressurePumpDay") @GetMapping(value = "/getPressurePumpDay")
@ApiOperation(httpMethod = "GET", value = "手动-存储昨日稳压泵启动次数", notes = "手动-存储昨日稳压泵启动次数") @ApiOperation(httpMethod = "GET", value = "手动-存储昨日稳压泵启动次数", notes = "手动-存储昨日稳压泵启动次数")
public ResponseModel getPressurePumpDay(@RequestParam(required = false) String bizOrgCode) { public ResponseModel getPressurePumpDay() {
if(StringUtils.isEmpty(bizOrgCode)) { return CommonResponseUtil.success(iEmergencyService.getPressurePumpDay());
ReginParams reginParams = getSelectedOrgInfo();
ReginParams.PersonIdentity personIdentity = reginParams.getPersonIdentity();
if (!ValidationUtil.isEmpty(personIdentity)) {
bizOrgCode = personIdentity.getBizOrgCode();
if (bizOrgCode == null) {
return CommonResponseUtil.success(Collections.EMPTY_LIST);
}
}
}
return CommonResponseUtil.success(iEmergencyService.getPressurePumpDay(bizOrgCode));
} }
@PersonIdentify @PersonIdentify
......
package com.yeejoin.equipmanage.mapper; package com.yeejoin.equipmanage.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.equipmanage.common.dto.OrgUsrDto;
import com.yeejoin.equipmanage.common.entity.OrgUsr; import com.yeejoin.equipmanage.common.entity.OrgUsr;
import java.util.List; import java.util.List;
import java.util.Map;
public interface OrgUsrMapper extends BaseMapper<OrgUsr> { public interface OrgUsrMapper extends BaseMapper<OrgUsr> {
...@@ -11,4 +13,5 @@ public interface OrgUsrMapper extends BaseMapper<OrgUsr> { ...@@ -11,4 +13,5 @@ public interface OrgUsrMapper extends BaseMapper<OrgUsr> {
List<OrgUsr> getCompanyTree(); List<OrgUsr> getCompanyTree();
List<OrgUsrDto> getOrgUsrDtoInfo(Map<String, String> map);
} }
\ No newline at end of file
...@@ -61,7 +61,7 @@ public interface IEmergencyService { ...@@ -61,7 +61,7 @@ public interface IEmergencyService {
Page<Map<String, Object>> alarmList(Page<Map<String, Object>> page,String bizOrgCode, List<String> types, List<String> emergencyLevels, String name, Integer cleanStatus, Integer handleStatus); Page<Map<String, Object>> alarmList(Page<Map<String, Object>> page,String bizOrgCode, List<String> types, List<String> emergencyLevels, String name, Integer cleanStatus, Integer handleStatus);
Map<String, List<PressurePumpCountVo>> getPressurePumpDay(String bizOrgCode); Map<String, List<PressurePumpCountVo>> getPressurePumpDay();
/** /**
* 稳压泵启动统计 * 稳压泵启动统计
......
package com.yeejoin.equipmanage.service; package com.yeejoin.equipmanage.service;
import com.yeejoin.equipmanage.common.dto.OrgUsrDto;
import com.yeejoin.equipmanage.common.vo.IotDataVO; import com.yeejoin.equipmanage.common.vo.IotDataVO;
import com.yeejoin.equipmanage.common.vo.PressurePumpCountVo; import com.yeejoin.equipmanage.common.vo.PressurePumpCountVo;
...@@ -19,7 +20,6 @@ public interface IPressurePumpService { ...@@ -19,7 +20,6 @@ public interface IPressurePumpService {
* *
* @param iotDatalist * @param iotDatalist
* @param iotCode * @param iotCode
* @param bizOrgCode
*/ */
void saveDataToRedis(List<IotDataVO> iotDatalist, String iotCode, String bizOrgCode); void saveDataToRedis(List<IotDataVO> iotDatalist, String iotCode, String bizOrgCode);
...@@ -171,4 +171,11 @@ public interface IPressurePumpService { ...@@ -171,4 +171,11 @@ public interface IPressurePumpService {
* @return * @return
*/ */
Map<String, List<PressurePumpCountVo>> getDateRangeCountList(List<Map<String, Object>> pumpInfoList, String startTime, String endTime, String infoCode, String countRedisKey, String equipmentCode, String nameKey, long countExpire, String bizOrgCode); Map<String, List<PressurePumpCountVo>> getDateRangeCountList(List<Map<String, Object>> pumpInfoList, String startTime, String endTime, String infoCode, String countRedisKey, String equipmentCode, String nameKey, long countExpire, String bizOrgCode);
/**
* 获取OrgUsr信息
* @param map
* @return
*/
List<OrgUsrDto> getOrgUsrDtoInfo(Map<String, String> map);
} }
...@@ -2,6 +2,7 @@ package com.yeejoin.equipmanage.service.impl; ...@@ -2,6 +2,7 @@ package com.yeejoin.equipmanage.service.impl;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.utils.DateUtils; import com.yeejoin.amos.boot.biz.common.utils.DateUtils;
import com.yeejoin.equipmanage.common.dto.OrgUsrDto;
import com.yeejoin.equipmanage.common.entity.EquipmentSpecificAlarmLog; import com.yeejoin.equipmanage.common.entity.EquipmentSpecificAlarmLog;
import com.yeejoin.equipmanage.common.enums.IndexStatusEnum; import com.yeejoin.equipmanage.common.enums.IndexStatusEnum;
import com.yeejoin.equipmanage.common.enums.PressurePumpAnalysisEnum; import com.yeejoin.equipmanage.common.enums.PressurePumpAnalysisEnum;
...@@ -465,11 +466,11 @@ public class EmergencyServiceImpl implements IEmergencyService { ...@@ -465,11 +466,11 @@ public class EmergencyServiceImpl implements IEmergencyService {
@Scheduled(cron = "${equipment.pressurepump.start.cron}") @Scheduled(cron = "${equipment.pressurepump.start.cron}")
private void stationDoubleReport() { private void stationDoubleReport() {
System.out.println("开始定时存储昨日稳压泵启动次数,定时时间为:" + pumpYesterdayStart); System.out.println("开始定时存储昨日稳压泵启动次数,定时时间为:" + pumpYesterdayStart);
getPressurePumpDay(null); getPressurePumpDay();
} }
@Override @Override
public Map<String, List<PressurePumpCountVo>> getPressurePumpDay(String bizOrgCode) { public Map<String, List<PressurePumpCountVo>> getPressurePumpDay() {
Map<String, List<PressurePumpCountVo>> dataMap = new HashMap<>(); Map<String, List<PressurePumpCountVo>> dataMap = new HashMap<>();
// 从 json 配置文件获取配置信息 // 从 json 配置文件获取配置信息
List<Map> infoList = pressurePumpService.getNameKeyInfoList(PressurePumpRelateEnum.PRESSURE_PUMP.getValue()); List<Map> infoList = pressurePumpService.getNameKeyInfoList(PressurePumpRelateEnum.PRESSURE_PUMP.getValue());
...@@ -484,19 +485,29 @@ public class EmergencyServiceImpl implements IEmergencyService { ...@@ -484,19 +485,29 @@ public class EmergencyServiceImpl implements IEmergencyService {
String equipmentCode = infoMap.get("equipmentCode").toString(); String equipmentCode = infoMap.get("equipmentCode").toString();
String countRedisKey = infoMap.get("countRedisKey").toString(); String countRedisKey = infoMap.get("countRedisKey").toString();
long countExpire = Long.parseLong(infoMap.get("countExpire").toString()); long countExpire = Long.parseLong(infoMap.get("countExpire").toString());
List<Map<String, Object>> pumpInfoList = equipmentSpecificSerivce.getFirePumpInfoEQ(equipmentCode, bizOrgCode); List<Map<String, Object>> pumpInfoList = equipmentSpecificSerivce.getFirePumpInfoEQ(equipmentCode, null);
if (!CollectionUtils.isEmpty(pumpInfoList)){ if (!CollectionUtils.isEmpty(pumpInfoList)){
Map<String, String> params = new HashMap<>();
for (Map<String, Object> map : pumpInfoList) { for (Map<String, Object> map : pumpInfoList) {
// iot获取数据,返回并存储redis // iot获取数据,返回并存储redis
Object iotCode = map.get("iotCode"); Object iotCode = map.get("iotCode");
Object orgCode = map.get("bizOrgCode"); Object orgCode = map.get("bizOrgCode");
bizOrgCode = StringUtils.isNotBlank(bizOrgCode) ? bizOrgCode : ObjectUtils.isEmpty(orgCode) ? "" : orgCode.toString(); String bizOrgCode = ObjectUtils.isEmpty(orgCode) ? "" : orgCode.toString();
if (!ObjectUtils.isEmpty(iotCode) && !ObjectUtils.isEmpty(bizOrgCode)) { if (!ObjectUtils.isEmpty(iotCode) && !ObjectUtils.isEmpty(bizOrgCode)) {
String iotCodeStr = iotCode.toString(); // 获取公司顶级bizOrgCode
String prefix = ObjectUtils.isEmpty(iotCode) ? "" : iotCodeStr.substring(0, 8); params.put("bizOrgType", PressurePumpRelateEnum.BIZ_ORG_TYPE_COMPANY.getValue());
String suffix = ObjectUtils.isEmpty(iotCode) ? "" : iotCodeStr.substring(8); params.put("bizOrgCode", bizOrgCode);
List<PressurePumpCountVo> dataList = pressurePumpService.getIotCountData(startTime, endTime, PressurePumpRelateEnum.PRESSURE_PUMP.getValue(), countRedisKey, prefix, suffix, PressurePumpRelateEnum.IOT_INDEX_VALUE_TRUE.getValue(), pressurePumpStart, countExpire, bizOrgCode); List<OrgUsrDto> orgUsrDtoList = pressurePumpService.getOrgUsrDtoInfo(params);
dataMap.put(iotCodeStr, dataList); if (!CollectionUtils.isEmpty(orgUsrDtoList)) {
bizOrgCode = orgUsrDtoList.get(0).getBizOrgCode();
if (StringUtils.isNotBlank(bizOrgCode)) {
String iotCodeStr = iotCode.toString();
String prefix = ObjectUtils.isEmpty(iotCode) ? "" : iotCodeStr.substring(0, 8);
String suffix = ObjectUtils.isEmpty(iotCode) ? "" : iotCodeStr.substring(8);
List<PressurePumpCountVo> dataList = pressurePumpService.getIotCountData(startTime, endTime, PressurePumpRelateEnum.PRESSURE_PUMP.getValue(), countRedisKey, prefix, suffix, PressurePumpRelateEnum.IOT_INDEX_VALUE_TRUE.getValue(), pressurePumpStart, countExpire, bizOrgCode);
dataMap.put(iotCodeStr, dataList);
}
}
} }
} }
} }
......
...@@ -4,10 +4,12 @@ import com.alibaba.fastjson.JSON; ...@@ -4,10 +4,12 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.yeejoin.amos.boot.biz.common.utils.DateUtils; import com.yeejoin.amos.boot.biz.common.utils.DateUtils;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils; import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.equipmanage.common.dto.OrgUsrDto;
import com.yeejoin.equipmanage.common.enums.PressurePumpRelateEnum; import com.yeejoin.equipmanage.common.enums.PressurePumpRelateEnum;
import com.yeejoin.equipmanage.common.vo.IotDataVO; import com.yeejoin.equipmanage.common.vo.IotDataVO;
import com.yeejoin.equipmanage.common.vo.PressurePumpCountVo; import com.yeejoin.equipmanage.common.vo.PressurePumpCountVo;
import com.yeejoin.equipmanage.fegin.IotFeign; import com.yeejoin.equipmanage.fegin.IotFeign;
import com.yeejoin.equipmanage.mapper.OrgUsrMapper;
import com.yeejoin.equipmanage.service.IPressurePumpService; import com.yeejoin.equipmanage.service.IPressurePumpService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
...@@ -40,6 +42,9 @@ public class PressurePumpServiceImpl implements IPressurePumpService { ...@@ -40,6 +42,9 @@ public class PressurePumpServiceImpl implements IPressurePumpService {
@Autowired @Autowired
private RedisUtils redisUtils; private RedisUtils redisUtils;
@Autowired
private OrgUsrMapper orgUsrMapper;
@Value("classpath:/json/nameKeyInfo.json") @Value("classpath:/json/nameKeyInfo.json")
private Resource nameKeyInfo; private Resource nameKeyInfo;
...@@ -52,20 +57,30 @@ public class PressurePumpServiceImpl implements IPressurePumpService { ...@@ -52,20 +57,30 @@ public class PressurePumpServiceImpl implements IPressurePumpService {
@Override @Override
@Async @Async
public void saveDataToRedis(List<IotDataVO> iotDatalist, String iotCode, String bizOrgCode) { public void saveDataToRedis(List<IotDataVO> iotDatalist, String iotCode, String bizOrgCode) {
String pressurePumpValue = PressurePumpRelateEnum.PRESSURE_PUMP.getValue(); // 获取公司顶级bizOrgCode
// 获取配置JSON信息集合 Map<String, String> params = new HashMap<>();
List<Map> list = getNameKeyInfoList(pressurePumpValue); params.put("bizOrgType", PressurePumpRelateEnum.BIZ_ORG_TYPE_COMPANY.getValue());
if (CollectionUtils.isNotEmpty(list) && StringUtils.isNotBlank(iotCode) && StringUtils.isNotBlank(bizOrgCode)) { params.put("bizOrgCode", bizOrgCode);
Map map = list.get(0); List<OrgUsrDto> orgUsrDtoList = getOrgUsrDtoInfo(params);
String nameKey = map.get("nameKey").toString(); if (CollectionUtils.isNotEmpty(orgUsrDtoList)) {
int expire = Integer.parseInt(map.get("expire").toString()); bizOrgCode = orgUsrDtoList.get(0).getBizOrgCode();
String nowString = DateUtils.getDateNowString(); if (StringUtils.isNotBlank(bizOrgCode)) {
long timeMillis = System.currentTimeMillis(); String pressurePumpValue = PressurePumpRelateEnum.PRESSURE_PUMP.getValue();
for (IotDataVO vo : iotDatalist) { // 获取配置JSON信息集合
String key = vo.getKey(); List<Map> list = getNameKeyInfoList(pressurePumpValue);
if (nameKey.contains(vo.getKey())) { if (CollectionUtils.isNotEmpty(list) && StringUtils.isNotBlank(iotCode) && StringUtils.isNotBlank(bizOrgCode)) {
vo.setCreatedTime(nowString); Map map = list.get(0);
redisUtils.set(String.join(":", pressurePumpValue, bizOrgCode, key, iotCode, String.valueOf(timeMillis)), JSON.toJSONString(vo), expire); String nameKey = map.get("nameKey").toString();
int expire = Integer.parseInt(map.get("expire").toString());
String nowString = DateUtils.getDateNowString();
long timeMillis = System.currentTimeMillis();
for (IotDataVO vo : iotDatalist) {
String key = vo.getKey();
if (nameKey.contains(vo.getKey())) {
vo.setCreatedTime(nowString);
redisUtils.set(String.join(":", pressurePumpValue, bizOrgCode, key, iotCode, String.valueOf(timeMillis)), JSON.toJSONString(vo), expire);
}
}
} }
} }
} }
...@@ -395,4 +410,8 @@ public class PressurePumpServiceImpl implements IPressurePumpService { ...@@ -395,4 +410,8 @@ public class PressurePumpServiceImpl implements IPressurePumpService {
return Collections.emptyList(); return Collections.emptyList();
} }
public List<OrgUsrDto> getOrgUsrDtoInfo(Map<String, String> map) {
return orgUsrMapper.getOrgUsrDtoInfo(map);
}
} }
...@@ -53,4 +53,19 @@ ...@@ -53,4 +53,19 @@
) )
) )
</select> </select>
<select id="getOrgUsrDtoInfo" resultType="com.yeejoin.equipmanage.common.dto.OrgUsrDto">
SELECT
biz_org_code bizOrgCode,
biz_org_name bizOrgName
FROM
cb_org_usr
<where>
<if test="bizOrgType != null and bizOrgType != ''">
biz_org_type = #{bizOrgType}
</if>
<if test="bizOrgCode != null and bizOrgCode != ''">
AND locate( #{bizOrgCode}, biz_org_code ) > 0
</if>
</where>
</select>
</mapper> </mapper>
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