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

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

parent 53845507
......@@ -29,6 +29,7 @@ public enum PressurePumpRelateEnum {
STOP("0", "停止"),
RESET("2", "复位"),
CREATED_TIME("createdTime", "物联采集信号创建时间属性"),
BIZ_ORG_TYPE_COMPANY("COMPANY", "bizOrgType之公司"),
UN_CLEAN_TIME("false", "未消除");
private final String value;
......
......@@ -634,18 +634,8 @@ public class EmergencyController extends AbstractBaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/getPressurePumpDay")
@ApiOperation(httpMethod = "GET", value = "手动-存储昨日稳压泵启动次数", notes = "手动-存储昨日稳压泵启动次数")
public ResponseModel getPressurePumpDay(@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_LIST);
}
}
}
return CommonResponseUtil.success(iEmergencyService.getPressurePumpDay(bizOrgCode));
public ResponseModel getPressurePumpDay() {
return CommonResponseUtil.success(iEmergencyService.getPressurePumpDay());
}
@PersonIdentify
......
package com.yeejoin.equipmanage.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.equipmanage.common.dto.OrgUsrDto;
import com.yeejoin.equipmanage.common.entity.OrgUsr;
import java.util.List;
import java.util.Map;
public interface OrgUsrMapper extends BaseMapper<OrgUsr> {
......@@ -11,4 +13,5 @@ public interface OrgUsrMapper extends BaseMapper<OrgUsr> {
List<OrgUsr> getCompanyTree();
List<OrgUsrDto> getOrgUsrDtoInfo(Map<String, String> map);
}
\ No newline at end of file
......@@ -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);
Map<String, List<PressurePumpCountVo>> getPressurePumpDay(String bizOrgCode);
Map<String, List<PressurePumpCountVo>> getPressurePumpDay();
/**
* 稳压泵启动统计
......
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.PressurePumpCountVo;
......@@ -19,7 +20,6 @@ public interface IPressurePumpService {
*
* @param iotDatalist
* @param iotCode
* @param bizOrgCode
*/
void saveDataToRedis(List<IotDataVO> iotDatalist, String iotCode, String bizOrgCode);
......@@ -171,4 +171,11 @@ public interface IPressurePumpService {
* @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);
/**
* 获取OrgUsr信息
* @param map
* @return
*/
List<OrgUsrDto> getOrgUsrDtoInfo(Map<String, String> map);
}
......@@ -2,6 +2,7 @@ package com.yeejoin.equipmanage.service.impl;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
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.enums.IndexStatusEnum;
import com.yeejoin.equipmanage.common.enums.PressurePumpAnalysisEnum;
......@@ -465,11 +466,11 @@ public class EmergencyServiceImpl implements IEmergencyService {
@Scheduled(cron = "${equipment.pressurepump.start.cron}")
private void stationDoubleReport() {
System.out.println("开始定时存储昨日稳压泵启动次数,定时时间为:" + pumpYesterdayStart);
getPressurePumpDay(null);
getPressurePumpDay();
}
@Override
public Map<String, List<PressurePumpCountVo>> getPressurePumpDay(String bizOrgCode) {
public Map<String, List<PressurePumpCountVo>> getPressurePumpDay() {
Map<String, List<PressurePumpCountVo>> dataMap = new HashMap<>();
// 从 json 配置文件获取配置信息
List<Map> infoList = pressurePumpService.getNameKeyInfoList(PressurePumpRelateEnum.PRESSURE_PUMP.getValue());
......@@ -484,14 +485,22 @@ public class EmergencyServiceImpl implements IEmergencyService {
String equipmentCode = infoMap.get("equipmentCode").toString();
String countRedisKey = infoMap.get("countRedisKey").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)){
Map<String, String> params = new HashMap<>();
for (Map<String, Object> map : pumpInfoList) {
// iot获取数据,返回并存储redis
Object iotCode = map.get("iotCode");
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)) {
// 获取公司顶级bizOrgCode
params.put("bizOrgType", PressurePumpRelateEnum.BIZ_ORG_TYPE_COMPANY.getValue());
params.put("bizOrgCode", bizOrgCode);
List<OrgUsrDto> orgUsrDtoList = pressurePumpService.getOrgUsrDtoInfo(params);
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);
......@@ -500,6 +509,8 @@ public class EmergencyServiceImpl implements IEmergencyService {
}
}
}
}
}
} catch (ParseException e) {
log.error("redis存稳压泵昨天启动次数失败:{}", e.getMessage());
}
......
......@@ -4,10 +4,12 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.yeejoin.amos.boot.biz.common.utils.DateUtils;
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.vo.IotDataVO;
import com.yeejoin.equipmanage.common.vo.PressurePumpCountVo;
import com.yeejoin.equipmanage.fegin.IotFeign;
import com.yeejoin.equipmanage.mapper.OrgUsrMapper;
import com.yeejoin.equipmanage.service.IPressurePumpService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
......@@ -40,6 +42,9 @@ public class PressurePumpServiceImpl implements IPressurePumpService {
@Autowired
private RedisUtils redisUtils;
@Autowired
private OrgUsrMapper orgUsrMapper;
@Value("classpath:/json/nameKeyInfo.json")
private Resource nameKeyInfo;
......@@ -52,6 +57,14 @@ public class PressurePumpServiceImpl implements IPressurePumpService {
@Override
@Async
public void saveDataToRedis(List<IotDataVO> iotDatalist, String iotCode, String bizOrgCode) {
// 获取公司顶级bizOrgCode
Map<String, String> params = new HashMap<>();
params.put("bizOrgType", PressurePumpRelateEnum.BIZ_ORG_TYPE_COMPANY.getValue());
params.put("bizOrgCode", bizOrgCode);
List<OrgUsrDto> orgUsrDtoList = getOrgUsrDtoInfo(params);
if (CollectionUtils.isNotEmpty(orgUsrDtoList)) {
bizOrgCode = orgUsrDtoList.get(0).getBizOrgCode();
if (StringUtils.isNotBlank(bizOrgCode)) {
String pressurePumpValue = PressurePumpRelateEnum.PRESSURE_PUMP.getValue();
// 获取配置JSON信息集合
List<Map> list = getNameKeyInfoList(pressurePumpValue);
......@@ -70,6 +83,8 @@ public class PressurePumpServiceImpl implements IPressurePumpService {
}
}
}
}
}
@Override
public List<IotDataVO> getDataToRedis(String infoCode, String nameKey, String iotCode, String bizOrgCode) {
......@@ -395,4 +410,8 @@ public class PressurePumpServiceImpl implements IPressurePumpService {
return Collections.emptyList();
}
public List<OrgUsrDto> getOrgUsrDtoInfo(Map<String, String> map) {
return orgUsrMapper.getOrgUsrDtoInfo(map);
}
}
......@@ -53,4 +53,19 @@
)
)
</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>
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