Commit 8fb0d1e6 authored by tangwei's avatar tangwei

解决冲突

parents b1598822 fd0085fd
...@@ -11,7 +11,7 @@ public class RedisKey { ...@@ -11,7 +11,7 @@ public class RedisKey {
/**根据动态表单code获取动态表单列表*/ /**根据动态表单code获取动态表单列表*/
public static final String FORM_CODE = "form_code_"; public static final String FORM_CODE = "form_code_";
/**根据字典code获取数据字典列表*/ /**根据字典code获取数据字典列表*/
public static final String DATA_DICTIONARY_CODE= "data_dictionary_code_"; public static final String DATA_DICTIONARY_CODE= "data_dictionary_code_";
/**根据字典code获取数据字典列表*/ /**根据字典code获取数据字典列表*/
public static final String DATA_DICTIONARY_CODE_XIN= "data_dictionary_code_xin_"; public static final String DATA_DICTIONARY_CODE_XIN= "data_dictionary_code_xin_";
/**根据id获取消防人员基本信息*/ /**根据id获取消防人员基本信息*/
...@@ -42,7 +42,12 @@ public class RedisKey { ...@@ -42,7 +42,12 @@ public class RedisKey {
/** 企业用户注册前缀 */ /** 企业用户注册前缀 */
public static final String FLC_USER_TEL = "flc_tel_"; public static final String FLC_USER_TEL = "flc_tel_";
/**
* 装备指标Key值
*/
public static final String EQUIP_INDEX_ADDRESS = "equip_index_address";
/** 驼峰转下划线(简单写法,效率低于 ) */ /** 驼峰转下划线(简单写法,效率低于 ) */
public static String humpToLine(String str) { public static String humpToLine(String str) {
return str.replaceAll("[A-Z]", "_$0").toLowerCase(); return str.replaceAll("[A-Z]", "_$0").toLowerCase();
...@@ -69,7 +74,7 @@ public class RedisKey { ...@@ -69,7 +74,7 @@ public class RedisKey {
public static String buildPatternKey(String token) { public static String buildPatternKey(String token) {
return REGION_REDIS_PREFIX + "*" + "_" + token; return REGION_REDIS_PREFIX + "*" + "_" + token;
} }
/** /**
* 判断str1中包含str2的个数 * 判断str1中包含str2的个数
* @param str1 * @param str1
......
...@@ -69,4 +69,13 @@ public class EquipmentIndexVO { ...@@ -69,4 +69,13 @@ public class EquipmentIndexVO {
@ApiModelProperty(value = "指标枚举") @ApiModelProperty(value = "指标枚举")
private String valueEnum; private String valueEnum;
@ApiModelProperty(value = "信号的索引键key,用于唯一索引信号")
private String indexAddress;
@ApiModelProperty(value = "测点类型,analog/state")
private String dataType;
@ApiModelProperty(value = "网关标识")
private String gatewayId;
} }
...@@ -56,6 +56,12 @@ ...@@ -56,6 +56,12 @@
<artifactId>amos-component-security</artifactId> <artifactId>amos-component-security</artifactId>
<version>1.7.13-SNAPSHOT</version> <version>1.7.13-SNAPSHOT</version>
</dependency> </dependency>
<dependency>
<groupId>com.yeejoin</groupId>
<artifactId>amos-component-influxdb</artifactId>
<version>1.8.5-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies> </dependencies>
</project> </project>
package com.yeejoin.equipmanage.config;
import com.yeejoin.amos.boot.biz.common.utils.RedisKey;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.equipmanage.common.entity.vo.EquipmentIndexVO;
import com.yeejoin.equipmanage.mapper.EquipmentSpecificIndexMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
* @author LiuLin
* @date 2023/6/15
* @apiNote
*/
@Component
@Slf4j
public class EquipmentIndexCacheRunner implements CommandLineRunner {
@Resource
private EquipmentSpecificIndexMapper equipmentSpecificIndexMapper;
@Resource
private RedisUtils redisUtils;
@Override
public void run(String... args) throws Exception {
log.info(">>服务启动执行,执行预加载数据等操作");
redisUtils.del(RedisKey.EQUIP_INDEX_ADDRESS);
List<EquipmentIndexVO> equipSpecificIndexList = equipmentSpecificIndexMapper.getEquipSpecificIndexList(null);
Map<String, Object> equipmentIndexVOMap = equipSpecificIndexList.stream()
.filter(v -> v.getGatewayId() != null)
.collect(Collectors.toMap(vo -> vo.getIndexAddress() + "_" + vo.getGatewayId(), Function.identity()));
redisUtils.hmset(RedisKey.EQUIP_INDEX_ADDRESS, equipmentIndexVOMap);
}
}
...@@ -64,10 +64,10 @@ public class EquipmentIotMqttReceiveConfig { ...@@ -64,10 +64,10 @@ public class EquipmentIotMqttReceiveConfig {
@Value("${patrol.center.risk.topic}") @Value("${patrol.center.risk.topic}")
private String riskMsgCenterPatrolTopic; private String riskMsgCenterPatrolTopic;
private EquipmentSpecificMapper equipmentSpecificMapper; private EquipmentSpecificMapper equipmentSpecificMapper;
private MqttEventReceiveService mqttEventReceiveService; private MqttEventReceiveService mqttEventReceiveService;
private ISyncDataService iSyncDataService; private ISyncDataService iSyncDataService;
...@@ -76,10 +76,12 @@ public class EquipmentIotMqttReceiveConfig { ...@@ -76,10 +76,12 @@ public class EquipmentIotMqttReceiveConfig {
public void setEquipmentSpecificMapper(EquipmentSpecificMapper equipmentSpecificMapper) { public void setEquipmentSpecificMapper(EquipmentSpecificMapper equipmentSpecificMapper) {
this.equipmentSpecificMapper = equipmentSpecificMapper; this.equipmentSpecificMapper = equipmentSpecificMapper;
} }
@Autowired @Autowired
public void setMqttEventReceiveService(MqttEventReceiveService mqttEventReceiveService) { public void setMqttEventReceiveService(MqttEventReceiveService mqttEventReceiveService) {
this.mqttEventReceiveService = mqttEventReceiveService; this.mqttEventReceiveService = mqttEventReceiveService;
} }
@Autowired @Autowired
public void setiSyncDataService(ISyncDataService iSyncDataService) { public void setiSyncDataService(ISyncDataService iSyncDataService) {
this.iSyncDataService = iSyncDataService; this.iSyncDataService = iSyncDataService;
...@@ -156,10 +158,10 @@ public class EquipmentIotMqttReceiveConfig { ...@@ -156,10 +158,10 @@ public class EquipmentIotMqttReceiveConfig {
mqttReceiveService.handlerMqttIncrementMessage(topic, msg); mqttReceiveService.handlerMqttIncrementMessage(topic, msg);
} else if (dataType.equals("event") && StringUtil.isNotEmpty(msg)) { } else if (dataType.equals("event") && StringUtil.isNotEmpty(msg)) {
mqttEventReceiveService.handlerMqttIncrementMessage(topic, msg); mqttEventReceiveService.handlerMqttIncrementMessage(topic, msg);
}else if (dataType.equals("transmit") && StringUtil.isNotEmpty(msg)){ } else if (dataType.equals("transmit") && StringUtil.isNotEmpty(msg)) {
mqttReceiveService.handlerMqttRomaMessage(topic,msg); mqttReceiveService.handlerMqttRomaMessage(topic, msg);
}else if (dataType.equals("perspective") && StringUtil.isNotEmpty(msg)){ } else if (dataType.equals("perspective") && StringUtil.isNotEmpty(msg)) {
mqttReceiveService.handlerMqttIotMessage(topic,msg); mqttReceiveService.handlerIotMessage(topic, msg);
} else if (dataType.equals("trigger") && StringUtil.isNotEmpty(msg)) { } else if (dataType.equals("trigger") && StringUtil.isNotEmpty(msg)) {
mqttReceiveService.handleDataToRiskModel(topic, msg); mqttReceiveService.handleDataToRiskModel(topic, msg);
} }
......
...@@ -224,7 +224,7 @@ public class CarController extends AbstractBaseController { ...@@ -224,7 +224,7 @@ public class CarController extends AbstractBaseController {
} }
}); });
} }
if (ObjectUtils.isEmpty(car.getName())) { if (!ObjectUtils.isEmpty(car.getEquipmentId())) {
Equipment equipment = iEquipmentService.getById(car.getEquipmentId()); Equipment equipment = iEquipmentService.getById(car.getEquipmentId());
car.setName(equipment != null ? equipment.getName() : null); car.setName(equipment != null ? equipment.getName() : null);
} }
...@@ -1444,8 +1444,8 @@ public class CarController extends AbstractBaseController { ...@@ -1444,8 +1444,8 @@ public class CarController extends AbstractBaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY,needAuth = false) @TycloudOperation(ApiLevel = UserType.AGENCY,needAuth = false)
@RequestMapping(value = "/getCarAreaInfo", method = RequestMethod.GET) @RequestMapping(value = "/getCarAreaInfo", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "车辆统计-获取片区车辆归属信息接口", notes = "车辆统计-获取片区车辆归属信息接口") @ApiOperation(httpMethod = "GET", value = "车辆统计-获取片区车辆归属信息接口", notes = "车辆统计-获取片区车辆归属信息接口")
public Page<CarAreaInfoDto> getCarAreaInfo(@RequestParam Long id) { public Page<CarAreaInfoDto> getCarAreaInfo(@RequestParam String areaName) {
return iCarService.getCarAreaInfo(id); return iCarService.getCarAreaInfo(areaName);
} }
@TycloudOperation(ApiLevel = UserType.AGENCY,needAuth = false) @TycloudOperation(ApiLevel = UserType.AGENCY,needAuth = false)
@RequestMapping(value = "/getCarMileageInfoByMoth", method = RequestMethod.GET) @RequestMapping(value = "/getCarMileageInfoByMoth", method = RequestMethod.GET)
...@@ -1455,11 +1455,11 @@ public class CarController extends AbstractBaseController { ...@@ -1455,11 +1455,11 @@ public class CarController extends AbstractBaseController {
} }
@TycloudOperation(ApiLevel = UserType.AGENCY,needAuth = false) @TycloudOperation(ApiLevel = UserType.AGENCY,needAuth = false)
@RequestMapping(value = "/exportCarMileageInfoByMoth", method = RequestMethod.GET) @RequestMapping(value = "/exportCarMileageInfoByMoth", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "车辆统计-按照月份统计车辆里程", notes = "车辆统计-按照月份统计车辆里程") @ApiOperation(httpMethod = "GET", value = "车辆统计-按照月份统计导出车辆里程", notes = "车辆统计-按照月份统计导出车辆里程")
public void exportCarMileageInfoByMoth(@RequestParam String date, HttpServletResponse response) { public void exportCarMileageInfoByMoth(@RequestParam String date, HttpServletResponse response) {
List<CarExportDto> list = this.iCarService.exportCarMileageInfoByMoth(date); List<CarExportDto> list = this.iCarService.exportCarMileageInfoByMoth(date);
String name = "车辆里程月度统计表-"+date; String name = "车辆里程月度统计表-"+date;
FileHelper.exportExcel(list,name,name,CarExportDto.class,UUID.randomUUID().toString()+".xls",response); FileHelper.exportExcel(list,name,name,CarExportDto.class,UUID.randomUUID().toString()+".xls",response);
} }
@TycloudOperation(ApiLevel = UserType.AGENCY,needAuth = false) @TycloudOperation(ApiLevel = UserType.AGENCY,needAuth = false)
@RequestMapping(value = "/getCarMileageInfoByMothOFDay", method = RequestMethod.GET) @RequestMapping(value = "/getCarMileageInfoByMothOFDay", method = RequestMethod.GET)
......
...@@ -28,6 +28,7 @@ import com.yeejoin.equipmanage.service.impl.FireFightingSystemServiceImpl; ...@@ -28,6 +28,7 @@ import com.yeejoin.equipmanage.service.impl.FireFightingSystemServiceImpl;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
...@@ -421,19 +422,19 @@ public class EquipmentSpecificController extends AbstractBaseController { ...@@ -421,19 +422,19 @@ public class EquipmentSpecificController extends AbstractBaseController {
EquipmentSpecific spec = equipmentSpecificSerivce.getBaseMapper().selectById(id); EquipmentSpecific spec = equipmentSpecificSerivce.getBaseMapper().selectById(id);
int oldStatus = Integer.valueOf(spec.getEquipStatus()); int oldStatus = Integer.valueOf(spec.getEquipStatus());
int newStatus = Integer.valueOf(status); int newStatus = Integer.valueOf(status);
if (oldStatus >= newStatus){
//保存 wl_equip_qrcode_record 二维码记录 //保存 wl_equip_qrcode_record 二维码记录
EquipQrcodeRecord equipQrcodeRecord = new EquipQrcodeRecord(); EquipQrcodeRecord equipQrcodeRecord = new EquipQrcodeRecord();
equipQrcodeRecord.setEquipid(Long.valueOf(id)); equipQrcodeRecord.setEquipid(Long.valueOf(id));
equipQrcodeRecord.setSource(source); equipQrcodeRecord.setSource(source);
equipQrcodeRecord.setAlarmTime(new Date()); equipQrcodeRecord.setAlarmTime(new Date());
equipQrcodeRecord.setStatus(status); equipQrcodeRecord.setStatus(status);
equipQrcodeRecord.setSourceId(Long.valueOf(sourceId)); equipQrcodeRecord.setSourceId(Long.valueOf(sourceId));
equipQrcodeRecord.setBizOrgCode(spec.getBizOrgCode()); equipQrcodeRecord.setBizOrgCode(spec.getBizOrgCode());
equipQrcodeRecord.setBizOrgName(spec.getBizOrgName()); equipQrcodeRecord.setBizOrgName(spec.getBizOrgName());
equipQrcodeRecord.setSystemCode(spec.getSystemId()); equipQrcodeRecord.setSystemCode(spec.getSystemId());
equipQrcodeRecordMapper.insert(equipQrcodeRecord); equipQrcodeRecordMapper.insert(equipQrcodeRecord);
}else { if (oldStatus < newStatus){ //当前状态小于事件状态时 取更高级别状态赋码
equipmentSpecificSerivce.updateEquipSpecificStatus(status, id); equipmentSpecificSerivce.updateEquipSpecificStatus(status, id);
} }
return CommonResponseUtil.success(); return CommonResponseUtil.success();
...@@ -441,17 +442,29 @@ public class EquipmentSpecificController extends AbstractBaseController { ...@@ -441,17 +442,29 @@ public class EquipmentSpecificController extends AbstractBaseController {
@GetMapping(value = "/status/checkInput") @GetMapping(value = "/status/checkInput")
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "idx修改巡检项对应装备二维码状态", notes = "idx修改巡检项对应装备二维码状态") @ApiOperation(httpMethod = "GET", value = "idx修改对应装备二维码状态", notes = "idx修改对应装备二维码状态")
public ResponseModel updateEquipSpecificStatusByCheckInput( String id){ public ResponseModel updateEquipSpecificStatusByCheckInput( @RequestParam(value = "id") String id,@RequestParam(value = "equipId",required = false) String equipId ){
//查询 巡检项所绑定装备 //查询 巡检项所绑定装备
String equipId = equipmentSpecificSerivce.updateEquipSpecificStatusByCheckInput(id); if (StringUtils.isEmpty(equipId)){
equipId = equipmentSpecificSerivce.updateEquipSpecificStatusByCheckInput(id);
}
LambdaQueryWrapper<EquipQrcodeRecord> query = new LambdaQueryWrapper<>(); LambdaQueryWrapper<EquipQrcodeRecord> query = new LambdaQueryWrapper<>();
query.eq(EquipQrcodeRecord::getEquipid,equipId); query.eq(EquipQrcodeRecord::getEquipid,equipId);
query.notIn(EquipQrcodeRecord::getSourceId,id);
query.isNull(EquipQrcodeRecord::getCleanTime); query.isNull(EquipQrcodeRecord::getCleanTime);
List<EquipQrcodeRecord> equipQrcodeRecords = equipQrcodeRecordMapper.selectList(query); List<EquipQrcodeRecord> equipQrcodeRecords = equipQrcodeRecordMapper.selectList(query);
if (equipQrcodeRecords.size() == 0) { //如果记录表中此装备无未消除的故障等 则恢复绿码 if (equipQrcodeRecords.size() == 0) { //如果记录表中此装备无未消除的故障等 则恢复绿码
//修改装备二维码状态为合格 此处为0代表绿色 是idx只有在合格是才会触发此接口 //修改装备二维码状态为合格 此处为0代表绿色 是idx只有在合格是才会触发此接口
equipmentSpecificSerivce.updateEquipSpecificStatus("0", equipId); equipmentSpecificSerivce.updateEquipSpecificStatus("0", equipId);
} else {
//先修改本次清除的装备事件
EquipQrcodeRecord equipQrcodeRecord = equipQrcodeRecords.stream().filter(e -> e.getSourceId().equals(id)).findFirst().get();
equipQrcodeRecords.remove(equipQrcodeRecord);
equipQrcodeRecord.setCleanTime(new Date());
equipQrcodeRecordMapper.updateById(equipQrcodeRecord);
//然后取结果集中剩余状态最高的颜色赋码
String status = equipQrcodeRecords.stream().sorted(Comparator.comparing(EquipQrcodeRecord::getStatus)).findFirst().get().getStatus();
equipmentSpecificSerivce.updateEquipSpecificStatus(status, equipId);
} }
return CommonResponseUtil.success(); return CommonResponseUtil.success();
} }
......
...@@ -71,7 +71,7 @@ public class CarIotNewListener extends EmqxListener { ...@@ -71,7 +71,7 @@ public class CarIotNewListener extends EmqxListener {
this.updateCarLocation(jsonObject, iotCode); this.updateCarLocation(jsonObject, iotCode);
//如果map中已经存在该设备或者该设备有但是线程已经执行了 //如果map中已经存在该设备或者该设备有但是线程已经执行了
if ((!deviceInfo.containsKey(iotCode)) || (deviceInfo.containsKey(iotCode) && deviceInfo.get(iotCode) == null)) { if ((!deviceInfo.containsKey(iotCode)) || (deviceInfo.containsKey(iotCode) && deviceInfo.get(iotCode) == null)) {
ThreadCar threadCar = new ThreadCar(iotCode, jsonObject, this.iWlCarMileageService, this.iotFeign, this.iCarService, this.emqkeeper, clipping_time); ThreadCar threadCar = new ThreadCar(topic, jsonObject, this.iWlCarMileageService, this.iotFeign, this.iCarService, this.emqkeeper, clipping_time);
deviceInfo.put(iotCode, threadCar); deviceInfo.put(iotCode, threadCar);
threadCar.start(); threadCar.start();
} }
...@@ -87,7 +87,7 @@ public class CarIotNewListener extends EmqxListener { ...@@ -87,7 +87,7 @@ public class CarIotNewListener extends EmqxListener {
deviceInfo.get(iotCode).interrupt(); deviceInfo.get(iotCode).interrupt();
} catch (Exception e) { } catch (Exception e) {
} }
ThreadCar threadCar = new ThreadCar(iotCode, jsonObject, this.iWlCarMileageService, this.iotFeign, this.iCarService, this.emqkeeper, clipping_time); ThreadCar threadCar = new ThreadCar(topic, jsonObject, this.iWlCarMileageService, this.iotFeign, this.iCarService, this.emqkeeper, clipping_time);
deviceInfo.put(iotCode, threadCar); deviceInfo.put(iotCode, threadCar);
//更新车辆的最新坐标数据 //更新车辆的最新坐标数据
deviceLastInfo.put(iotCode, coordinate); deviceLastInfo.put(iotCode, coordinate);
...@@ -104,7 +104,8 @@ public class CarIotNewListener extends EmqxListener { ...@@ -104,7 +104,8 @@ public class CarIotNewListener extends EmqxListener {
wlCarMileage.setStartLongitude(startLongitude); wlCarMileage.setStartLongitude(startLongitude);
wlCarMileage.setStartLatitude(startLatitude); wlCarMileage.setStartLatitude(startLatitude);
// Date startTime = UTCToCST(); // Date startTime = UTCToCST();
Date startTime = new Date(jsonObject.getLong("time")); //时间值被mysql自动转换
Date startTime = new Date((jsonObject.getLong("time")/1000)*1000);
wlCarMileage.setStartTime(startTime); wlCarMileage.setStartTime(startTime);
wlCarMileage.setStartName(getAddress(startLongitude, startLatitude)); wlCarMileage.setStartName(getAddress(startLongitude, startLatitude));
wlCarMileage.setStartSpeed(Double.valueOf(jsonObject.getDoubleValue("FireCar_Speed")).intValue()); wlCarMileage.setStartSpeed(Double.valueOf(jsonObject.getDoubleValue("FireCar_Speed")).intValue());
......
...@@ -202,7 +202,7 @@ public interface ICarService extends IService<Car> { ...@@ -202,7 +202,7 @@ public interface ICarService extends IService<Car> {
Page<CarEquipStateInfoDto> getCarEquipStateInfo(); Page<CarEquipStateInfoDto> getCarEquipStateInfo();
Page<CarEquipAlarmInfoDto> getCarEquipAlarmInfoDto(); Page<CarEquipAlarmInfoDto> getCarEquipAlarmInfoDto();
List<ChartIntegerDto>getCarBelongAreaInfo() ; List<ChartIntegerDto>getCarBelongAreaInfo() ;
Page<CarAreaInfoDto> getCarAreaInfo(Long id ) ; Page<CarAreaInfoDto> getCarAreaInfo(String areaName ) ;
Page<MileageDto> getCarMileageInfoByMoth(String date); Page<MileageDto> getCarMileageInfoByMoth(String date);
List<CarExportDto> exportCarMileageInfoByMoth(String date); List<CarExportDto> exportCarMileageInfoByMoth(String date);
ZZChartsDto getCarMileageInfoByMothOFDay(String iotCode); ZZChartsDto getCarMileageInfoByMothOFDay(String iotCode);
......
...@@ -13,28 +13,41 @@ public interface MqttReceiveService { ...@@ -13,28 +13,41 @@ public interface MqttReceiveService {
/** /**
* 增量数据处理 * 增量数据处理
* @param topic 主题 *
* @param topic 主题
* @param message 消息内容 * @param message 消息内容
*/ */
void handlerMqttIncrementMessage(String topic, String message); void handlerMqttIncrementMessage(String topic, String message);
/** /**
* 处理交换站消息数据 * 处理交换站消息数据
* @param topic 主题 *
* @param topic 主题
* @param message 消息内容 * @param message 消息内容
*/ */
void handlerMqttRomaMessage(String topic, String message); void handlerMqttRomaMessage(String topic, String message);
/** /**
* 处理Iot消息数据 * 处理Iot消息数据
* @param topic 主题 *
* @param topic 主题
* @param message 消息内容 * @param message 消息内容
*/ */
void handlerMqttIotMessage(String topic, String message); void handlerMqttIotMessage(String topic, String message);
/**
/**
* 中心级接收消息发送至消息服务 * 中心级接收消息发送至消息服务
*
* @param topic * @param topic
* @param message * @param message
*/ */
void handleDataToRiskModel(String topic, String message); void handleDataToRiskModel(String topic, String message);
/**
* 处理Iot消息数据
*
* @param topic 主题
* @param message 消息内容
*/
void handlerIotMessage(String topic, String message);
} }
...@@ -1826,23 +1826,26 @@ public class CarServiceImpl extends ServiceImpl<CarMapper, Car> implements ICarS ...@@ -1826,23 +1826,26 @@ public class CarServiceImpl extends ServiceImpl<CarMapper, Car> implements ICarS
} }
@Override @Override
public Page<CarAreaInfoDto> getCarAreaInfo( Long id) { public Page<CarAreaInfoDto> getCarAreaInfo( String areaName) {
Page<CarAreaInfoDto> page = new Page<>(); Page<CarAreaInfoDto> page = new Page<>();
List<CarAreaInfoDto> list = new ArrayList<>(); List<CarAreaInfoDto> list = new ArrayList<>();
FeignClientResult<java.util.Collection<CompanyModel>> de = Privilege.companyClient.querySubAgencyTree(id); CompanyModel companyModelArea= Privilege.companyClient.queryByCompanyName(areaName).getResult();
//如果是公司则获取所有片区 if(companyModelArea!=null){
ArrayList<CompanyModel> companyModels = (ArrayList<CompanyModel>) de.getResult(); FeignClientResult<java.util.Collection<CompanyModel>> de = Privilege.companyClient.querySubAgencyTree(companyModelArea.getSequenceNbr());
if (companyModels.size() >0 ) { //如果是公司则获取所有片区
for (int i = 0; i < companyModels.size(); i++) { ArrayList<CompanyModel> companyModels = (ArrayList<CompanyModel>) de.getResult();
CompanyModel companyModel = companyModels.get(i); if (companyModels.size() >0 ) {
CarAreaInfoDto carAreaInfoDto = new CarAreaInfoDto(); for (int i = 0; i < companyModels.size(); i++) {
Integer count = this.count(new QueryWrapper<Car>().like("biz_org_code", companyModel.getOrgCode())); CompanyModel companyModel = companyModels.get(i);
carAreaInfoDto.setNo(i+1); CarAreaInfoDto carAreaInfoDto = new CarAreaInfoDto();
carAreaInfoDto.setName(companyModel.getCompanyName()); Integer count = this.count(new QueryWrapper<Car>().like("biz_org_code", companyModel.getOrgCode()));
carAreaInfoDto.setCountOfCar(count); carAreaInfoDto.setNo(i+1);
list.add(carAreaInfoDto); carAreaInfoDto.setName(companyModel.getCompanyName());
} carAreaInfoDto.setCountOfCar(count);
} list.add(carAreaInfoDto);
}
}
}
page.setRecords(list); page.setRecords(list);
page.setTotal(list.size()); page.setTotal(list.size());
page.setCurrent(1); page.setCurrent(1);
......
...@@ -1714,16 +1714,18 @@ public class EquipmentSpecificSerivceImpl extends ServiceImpl<EquipmentSpecificM ...@@ -1714,16 +1714,18 @@ public class EquipmentSpecificSerivceImpl extends ServiceImpl<EquipmentSpecificM
@Override @Override
public void updateEquipmentSpecIndexRealtimeData(EquipmentSpecificIndex index) { public void updateEquipmentSpecIndexRealtimeData(EquipmentSpecificIndex index) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
if (!ObjectUtils.isEmpty(index)) { if (!ObjectUtils.isEmpty(index.getEquipmentSpecificId())) {
EquipmentSpecific es = equipmentSpecificMapper.selectById(index.getEquipmentSpecificId()); EquipmentSpecific es = equipmentSpecificMapper.selectById(index.getEquipmentSpecificId());
es.setRealtimeIotEsIndexId(index.getId()); if(!ObjectUtils.isEmpty(es)){
es.setRealtimeIotIndexKey(index.getNameKey()); es.setRealtimeIotEsIndexId(index.getId());
es.setRealtimeIotIndexName(index.getEquipmentSpecificIndexName()); es.setRealtimeIotIndexKey(index.getNameKey());
es.setRealtimeIotIndexValue(index.getValue()); es.setRealtimeIotIndexName(index.getEquipmentSpecificIndexName());
es.setRealtimeIotIndexId(index.getEquipmentIndexId()); es.setRealtimeIotIndexValue(index.getValue());
es.setRealtimeIotIndexUpdateDate(index.getUpdateDate()); es.setRealtimeIotIndexId(index.getEquipmentIndexId());
es.setValueLabel(index.getValueLabel()); es.setRealtimeIotIndexUpdateDate(index.getUpdateDate());
equipmentSpecificMapper.updateById(es); es.setValueLabel(index.getValueLabel());
equipmentSpecificMapper.updateById(es);
}
} }
} }
......
...@@ -12,6 +12,7 @@ import com.yeejoin.equipmanage.service.IWlCarMileageService; ...@@ -12,6 +12,7 @@ import com.yeejoin.equipmanage.service.IWlCarMileageService;
import com.yeejoin.equipmanage.utils.CarUtils; import com.yeejoin.equipmanage.utils.CarUtils;
import org.eclipse.paho.client.mqttv3.MqttException; import org.eclipse.paho.client.mqttv3.MqttException;
import org.eclipse.paho.client.mqttv3.MqttMessage; import org.eclipse.paho.client.mqttv3.MqttMessage;
import org.jfree.util.Log;
import org.typroject.tyboot.component.emq.EmqKeeper; import org.typroject.tyboot.component.emq.EmqKeeper;
import org.typroject.tyboot.core.restful.utils.ResponseModel; import org.typroject.tyboot.core.restful.utils.ResponseModel;
...@@ -50,6 +51,7 @@ public class ThreadCar extends Thread { ...@@ -50,6 +51,7 @@ public class ThreadCar extends Thread {
JSONObject lastObj = null; JSONObject lastObj = null;
WlCarMileage last = null; WlCarMileage last = null;
try { try {
Log.info("-------------------------" + this.topic + "结束坐标开始计时------------------------------");
this.sleep(clippingTime); this.sleep(clippingTime);
//业务处理 //业务处理
//如果十分钟没有坐标,则需要设置结束标记 //如果十分钟没有坐标,则需要设置结束标记
...@@ -84,18 +86,20 @@ public class ThreadCar extends Thread { ...@@ -84,18 +86,20 @@ public class ThreadCar extends Thread {
// JSONObject.parseObject(JSONObject.toJSONString(list.get(list.size() - 1))); // JSONObject.parseObject(JSONObject.toJSONString(list.get(list.size() - 1)));
if (lastObj == null) { if (lastObj == null) {
lastObj = new JSONObject(); lastObj = new JSONObject();
lastObj.put("FireCar_Longitude", 0.0); lastObj.put("FireCar_Longitude", last.getStartLongitude());
lastObj.put("FireCar_Latitude", 0.0); lastObj.put("FireCar_Latitude", last.getEndLatitude());
lastObj.put("time", 0); lastObj.put("time", 0);
lastObj.put("FireCar_Speed", 0); lastObj.put("FireCar_Speed", 0);
} }
double endLongitude = lastObj.getDoubleValue("FireCar_Longitude"); double endLongitude = lastObj.getDoubleValue("FireCar_Longitude");
double endLatitude = lastObj.getDoubleValue("FireCar_Latitude"); double endLatitude = lastObj.getDoubleValue("FireCar_Latitude");
// 230215180624
// Date endTime =UTCToCST(lastObj.getString("time"));
Date endTime = new Date(jsonObject.getLong("time")); Date endTime = new Date();
//实时库中的时间虽然坐标与记录的一致,但是更新时间可能最新,故可能会有记录的结束时间早于开始时间
long takeTime = (endTime.getTime() / 1000 * 1000) - (last.getStartTime().getTime() / 1000 * 1000); long takeTime = (endTime.getTime() / 1000 * 1000) - (last.getStartTime().getTime() / 1000 * 1000);
if(takeTime<0){
takeTime = 0-takeTime;
}
last.setEndLongitude(endLongitude); last.setEndLongitude(endLongitude);
last.setEndLatitude(endLatitude); last.setEndLatitude(endLatitude);
last.setEndTime(endTime); last.setEndTime(endTime);
...@@ -113,7 +117,7 @@ public class ThreadCar extends Thread { ...@@ -113,7 +117,7 @@ public class ThreadCar extends Thread {
} }
last.setTravel(new BigDecimal(travel / 1000).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue()); last.setTravel(new BigDecimal(travel / 1000).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue());
iWlCarMileageService.updateById(last); iWlCarMileageService.updateById(last);
System.out.println("============================================================更新结束坐标成功==========:"+topic); Log.info("============================================================更新结束坐标成功==========:"+topic);
this.interrupt(); this.interrupt();
} }
} catch (Exception exception) { } catch (Exception exception) {
......
package com.yeejoin.equipmanage.thread;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yeejoin.equipmanage.common.entity.Car;
import com.yeejoin.equipmanage.common.entity.WlCarMileage;
import com.yeejoin.equipmanage.common.utils.CoordinateUtil;
import com.yeejoin.equipmanage.fegin.IotFeign;
import com.yeejoin.equipmanage.service.ICarService;
import com.yeejoin.equipmanage.service.IWlCarMileageService;
import com.yeejoin.equipmanage.service.impl.CarServiceImpl;
import com.yeejoin.equipmanage.service.impl.WlCarMileageServiceImpl;
import com.yeejoin.equipmanage.utils.CarUtils;
import liquibase.pro.packaged.E;
import org.jfree.util.Log;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.typroject.tyboot.component.emq.EmqKeeper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
@Component
public class ThreadCarMileageTreatment extends Thread {
@Autowired
private WlCarMileageServiceImpl wlCarMileageServiceImpl;
@Autowired
CarServiceImpl carServiceImpl;
@Autowired
private IotFeign iotFeign;
@Value("${mileage.clippingtime}")
private Long clipping_time;
@Override
public void run() {
Log.info("----------------------------------------------------开始处理未结束里程---------------------------------");
HashMap<String, String> hashMap = new HashMap<>();
//toDo
WlCarMileage last = null;
JSONObject lastObj = null;
Car car =null;
List<WlCarMileage> wlCarMileageList = wlCarMileageServiceImpl.list(new QueryWrapper<WlCarMileage>().isNull("end_time"));
for (int i = 0; i < wlCarMileageList.size(); i++) {
car = carServiceImpl.getOne(new QueryWrapper<Car>().eq("iot_code", wlCarMileageList.get(i).getIotCode()));
String coordinateSting = String.valueOf(car.getLongitude()) + String.valueOf(car.getLatitude());
hashMap.put(car.getIotCode(), coordinateSting);
}
try {
Thread.sleep(clipping_time);
for (int i = 0; i < wlCarMileageList.size(); i++) {
WlCarMileage wlCarMileage =wlCarMileageList.get(i);
car = carServiceImpl.getOne(new QueryWrapper<Car>().eq("iot_code", wlCarMileage.getIotCode()));
String coordinateSting = String.valueOf(car.getLongitude()) + String.valueOf(car.getLatitude());
if (coordinateSting.equals(hashMap.get(car.getIotCode()))) {
String iotCode = car.getIotCode();
String measurement = "0THMcLKR";
String deviceName = iotCode.replace(measurement, "");
last = wlCarMileageServiceImpl
.getOne(new LambdaQueryWrapper<WlCarMileage>().eq(WlCarMileage::getIotCode, iotCode)
.isNull(WlCarMileage::getEndLongitude).isNull(WlCarMileage::getEndLatitude)
.orderByDesc(WlCarMileage::getStartTime).last("limit 1"));
ResponseModel<List<Object>> result = iotFeign.getLiveData(measurement, deviceName,
last.getStartTime(), new Date(new Date().getTime() + 2000));
List<Object> list = result.getResult();
if (list != null && list.size() > 0) {
// 过滤空坐标
List<Object> filterList = new ArrayList<Object>();
for (int j = 0; j < list.size(); j++) {
JSONObject Obj = JSONObject.parseObject(JSONObject.toJSONString(list.get(j)));
if (Obj.get("FireCar_Longitude") != null && Obj.get("FireCar_Latitude") != null
&& Obj.getDoubleValue("FireCar_Longitude") != 0
&& Obj.getDoubleValue("FireCar_Latitude") != 0) {
filterList.add(list.get(j));
// 获取第一个不为空的坐标
if (lastObj == null) {
lastObj = Obj;
}
}
}
Log.info("----------------------------------------lastobj----------------------"+lastObj.toJSONString());
if (lastObj == null) {
lastObj = new JSONObject();
lastObj.put("FireCar_Longitude", last.getStartLongitude());
lastObj.put("FireCar_Latitude", last.getEndLatitude());
lastObj.put("time", 0);
lastObj.put("FireCar_Speed", 0);
}
double endLongitude = lastObj.getDoubleValue("FireCar_Longitude");
double endLatitude = lastObj.getDoubleValue("FireCar_Latitude");
Date endTime = new Date();
long takeTime = (endTime.getTime() / 1000 * 1000) - (last.getStartTime().getTime() / 1000 * 1000);
if(takeTime<0){
takeTime = 0-takeTime;
}
last.setEndLongitude(endLongitude);
last.setEndLatitude(endLatitude);
last.setEndTime(endTime);
last.setEndName(CarUtils.getAddress(endLongitude, endLatitude));
last.setEndSpeed(lastObj.getIntValue("FireCar_Speed"));
last.setTakeTime(takeTime);
double travel = 0.0;
// 获取里程
for (int k = 0; k < filterList.size() - 1; k++) {
JSONObject start = JSONObject.parseObject(JSONObject.toJSONString(filterList.get(k)));
JSONObject end = JSONObject.parseObject(JSONObject.toJSONString(filterList.get(k + 1)));
travel += CoordinateUtil.distance(start.getDoubleValue("FireCar_Latitude"),
start.getDoubleValue("FireCar_Longitude"), end.getDoubleValue("FireCar_Latitude"),
end.getDoubleValue("FireCar_Longitude"));
}
last.setTravel(new BigDecimal(travel / 1000).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue());
Log.info("----------------------------------------last----------------------"+lastObj.toJSONString());
wlCarMileageServiceImpl.updateById(last);
}
}
}
} catch (Exception exception) {
exception.printStackTrace();
}
}
}
...@@ -3,6 +3,7 @@ package com.yeejoin; ...@@ -3,6 +3,7 @@ package com.yeejoin;
import com.yeejoin.amos.boot.biz.common.utils.oConvertUtils; import com.yeejoin.amos.boot.biz.common.utils.oConvertUtils;
import com.yeejoin.equipmanage.listener.CarIotListener; import com.yeejoin.equipmanage.listener.CarIotListener;
import com.yeejoin.equipmanage.listener.CarIotNewListener; import com.yeejoin.equipmanage.listener.CarIotNewListener;
import com.yeejoin.equipmanage.thread.ThreadCarMileageTreatment;
import org.eclipse.paho.client.mqttv3.MqttException; import org.eclipse.paho.client.mqttv3.MqttException;
import org.mybatis.spring.annotation.MapperScan; import org.mybatis.spring.annotation.MapperScan;
import org.slf4j.Logger; import org.slf4j.Logger;
...@@ -54,6 +55,10 @@ public class AmostEquipApplication { ...@@ -54,6 +55,10 @@ public class AmostEquipApplication {
@Autowired @Autowired
private CarIotNewListener carIotNewListener; private CarIotNewListener carIotNewListener;
@Autowired
private ThreadCarMileageTreatment threadCarMileageTreatment;
public static void main(String[] args) throws UnknownHostException { public static void main(String[] args) throws UnknownHostException {
ConfigurableApplicationContext context = SpringApplication.run(AmostEquipApplication.class, args); ConfigurableApplicationContext context = SpringApplication.run(AmostEquipApplication.class, args);
...@@ -82,4 +87,9 @@ public class AmostEquipApplication { ...@@ -82,4 +87,9 @@ public class AmostEquipApplication {
void initMqtt() throws MqttException { void initMqtt() throws MqttException {
emqKeeper.getMqttClient().subscribe("+/+/property", 1, carIotNewListener); emqKeeper.getMqttClient().subscribe("+/+/property", 1, carIotNewListener);
} }
//江西电建服务重启后对于未计时且未结束的里程的进行处理
@Bean
void initCarMelige() {
threadCarMileageTreatment.start();
}
} }
...@@ -139,4 +139,14 @@ mileage.clippingtime=600000 ...@@ -139,4 +139,14 @@ mileage.clippingtime=600000
equip.car.alarmBattery= 10 equip.car.alarmBattery= 10
equip.car.maxTravel=400 equip.car.maxTravel=400
equip.risk.model.topic="" equip.risk.model.topic=""
#mileage.segmentation.cron= 0 */2 * * * ? #mileage.segmentation.cron= 0 */2 * * * ?
\ No newline at end of file
# influxDB
spring.influx.url=http://172.16.11.201:8086
spring.influx.password=Yeejoin@2020
spring.influx.user=root
spring.influx.database=iot_platform
spring.influx.retention_policy=default
spring.influx.retention_policy_time=30d
spring.influx.actions=10000
spring.influx.bufferLimit=20000
\ No newline at end of file
...@@ -9,7 +9,7 @@ spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver ...@@ -9,7 +9,7 @@ spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
#mybatis mapper file #mybatis mapper file
mybatis.mapper-locations=classpath:mapper/*.xml mybatis.mapper-locations=classpath:mapper/*.xml
#mybatis-plus #mybatis-plus
mybatis-plus.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl mybatis-plus.configuration.log-impl=org.apache.ibatis.logging.slf4j.Slf4jImpl
# mybatis entity package # mybatis entity package
mybatis.type-aliases-package=com.yeejoin.equipmanage.common.entity mybatis.type-aliases-package=com.yeejoin.equipmanage.common.entity
spring.jackson.time-zone=GMT+8 spring.jackson.time-zone=GMT+8
......
...@@ -3870,5 +3870,16 @@ ...@@ -3870,5 +3870,16 @@
</sql> </sql>
</changeSet> </changeSet>
</databaseChangeLog> <changeSet author="ltw" id="20230614-ltw-01">
<preConditions onFail="MARK_RAN">
<not>
<columnExists tableName="cb_organization_user" columnName="post_name"/>
</not>
</preConditions>
<comment>modify table cb_organization_user modify columns</comment>
<sql>
ALTER TABLE `cb_organization_user` MODIFY `post_name` varchar(4000) DEFAULT NULL COMMENT '岗位名称'
</sql>
</changeSet>
</databaseChangeLog>
package com.yeejoin.amos;
import com.yeejoin.amos.message.kafka.KafkaProducerService;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class AmosBootUtilsMessageApplicationTests {
@Autowired
private KafkaProducerService kafkaProducerService;
@Test
void contextLoads() {
String msg = "hello";
kafkaProducerService.sendMessageAsync("akka.iot.created",msg);
}
}
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