结束时间已实现
parent
81632a5679
commit
42da762c53
|
@ -8,6 +8,7 @@ import org.springframework.cloud.openfeign.FeignClient;
|
|||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
|
||||
@FeignClient(contextId = "remoteTroubleService" ,
|
||||
value = ServiceNameConstants.BUSINESS_SERVICE,
|
||||
fallbackFactory = RemoteTroubleFallbackFactory.class
|
||||
|
@ -22,4 +23,11 @@ public interface RemoteTroubleService {
|
|||
@PostMapping("/trouble/newFaultData")
|
||||
public Result<?> newFaultData(@RequestBody CoupletTroubleCode code);
|
||||
|
||||
/**
|
||||
* 修改故障码
|
||||
* @param trouble
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/trouble/updEndTime")
|
||||
public int updEndTime(@RequestBody CoupletTroubleCode trouble);
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ import org.slf4j.LoggerFactory;
|
|||
import org.springframework.cloud.openfeign.FallbackFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
||||
/**
|
||||
* @author fufanrui
|
||||
* @version 1.0
|
||||
|
@ -26,9 +27,13 @@ public class RemoteTroubleFallbackFactory implements FallbackFactory<RemoteTroub
|
|||
|
||||
@Override
|
||||
public Result<?> newFaultData(CoupletTroubleCode code) {
|
||||
return Result.error("调用失败...."+cause.getMessage());
|
||||
return Result.error("调用失败...." + cause.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updEndTime(CoupletTroubleCode trouble) {
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package com.couplet.analyze.msg.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.couplet.analyze.common.contents.AnalyzeEventContents;
|
||||
import com.couplet.analyze.msg.contents.StateConstant;
|
||||
import com.couplet.analyze.msg.domain.CoupletMsgData;
|
||||
|
@ -85,10 +84,11 @@ public class BreakdownServiceImpl extends KeyExpirationEventMessageListener impl
|
|||
// log.info("故障事件检测结束.....");
|
||||
}else {
|
||||
long timeMillis = System.currentTimeMillis();
|
||||
Date date = MsgUtils.convertMillisToDateTimeSering(timeMillis);
|
||||
CoupletTroubleCode troubleCode = new CoupletTroubleCode();
|
||||
troubleCode.setTroubleEndTime(date);
|
||||
log.info("故障事件结束时间:"+date);
|
||||
troubleCode.setTroubleEndTime(new Date());
|
||||
troubleCode.setTroubleVin(coupletMsgData.getVin());
|
||||
remoteTroubleService.updEndTime(troubleCode);
|
||||
log.info("故障事件结束时间:"+timeMillis);
|
||||
log.info("故障事件结束.....");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ public class ElectronicFenceServiceImpl implements IncidentService {
|
|||
log.info("电子围栏事件redis存在.......");
|
||||
for (Fence fence : cacheSet) {
|
||||
String fenceLongitudeLatitude = fence.getFenceLongitudeLatitude();
|
||||
if (StringUtils.isEmpty(fenceLongitudeLatitude)){
|
||||
if (!StringUtils.isEmpty(fenceLongitudeLatitude)){
|
||||
/**
|
||||
* 先通过;后切割
|
||||
*/
|
||||
|
|
|
@ -8,7 +8,6 @@ import java.nio.charset.StandardCharsets;
|
|||
import java.time.Instant;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
@ -23,18 +22,14 @@ import java.util.Random;
|
|||
@Slf4j
|
||||
public class MsgUtils {
|
||||
|
||||
/**
|
||||
* 转换时间戳
|
||||
* @return
|
||||
*/
|
||||
public static Date convertMillisToDateTimeSering(Long millis) {
|
||||
public static Date convertMillisToDate(long millis) {
|
||||
Instant instant = Instant.ofEpochMilli(millis);
|
||||
LocalDateTime localDateTime = LocalDateTime.ofInstant(instant, ZoneId.systemDefault());
|
||||
return Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant());
|
||||
}
|
||||
|
||||
/***
|
||||
* 随机生成故障码
|
||||
/**
|
||||
* 生成GTA
|
||||
* @return
|
||||
*/
|
||||
public static String generateGTA() {
|
||||
|
|
|
@ -18,13 +18,13 @@ import java.util.regex.Pattern;
|
|||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
long timeMillis = System.currentTimeMillis();
|
||||
Date dateTime = convertMillisToDate(timeMillis);
|
||||
System.out.println("Date Time: " + dateTime);
|
||||
Date date = new Date(timeMillis);
|
||||
System.out.println(date);
|
||||
}
|
||||
|
||||
private static Date convertMillisToDate(long millis) {
|
||||
Instant instant = Instant.ofEpochMilli(millis);
|
||||
LocalDateTime localDateTime = LocalDateTime.ofInstant(instant, ZoneId.systemDefault());
|
||||
return Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant());
|
||||
}
|
||||
// private static Date convertMillisToDate(long millis) {
|
||||
// Instant instant = Instant.ofEpochMilli(millis);
|
||||
// LocalDateTime localDateTime = LocalDateTime.ofInstant(instant, ZoneId.systemDefault());
|
||||
// return Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant());
|
||||
// }
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -97,9 +98,9 @@ public class SysTroubleController extends BaseController {
|
|||
/**
|
||||
* 查询故障的状态并处理
|
||||
*/
|
||||
@PostMapping("/getUpdState")
|
||||
public Result<?> getUpdState(@RequestBody CoupletTroubleCode code) {
|
||||
int updateState = troubleService.updateState(code);
|
||||
return Result.success(updateState);
|
||||
@PostMapping("/updEndTime")
|
||||
public int updEndTime(@RequestBody CoupletTroubleCode trouble) {
|
||||
int i = troubleService.updEndTime(trouble);
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,9 @@ import com.couplet.common.domain.CoupletTroubleGrade;
|
|||
|
||||
import com.couplet.common.domain.request.TroubleResp;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -30,5 +32,7 @@ public interface SysTroubleMapper extends BaseMapper<CoupletTroubleCode> {
|
|||
|
||||
void cleanTroubleCode();
|
||||
|
||||
int updateState(CoupletTroubleCode code);
|
||||
int updEndTime(CoupletTroubleCode trouble);
|
||||
|
||||
List<CoupletTroubleCode> selectMaxTime();
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import com.couplet.common.domain.CoupletTroubleCode;
|
|||
import com.couplet.common.domain.CoupletTroubleGrade;
|
||||
import com.couplet.common.domain.request.TroubleResp;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -27,5 +28,5 @@ public interface SysTroubleService extends IService<CoupletTroubleCode> {
|
|||
|
||||
void cleanTroubleCode();
|
||||
|
||||
int updateState(CoupletTroubleCode code);
|
||||
int updEndTime(CoupletTroubleCode trouble);
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ import com.github.pagehelper.PageInfo;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -60,11 +61,17 @@ public class SysTroubleServiceImpl extends ServiceImpl<SysTroubleMapper, Couplet
|
|||
|
||||
/**
|
||||
* 获取故障状态
|
||||
* @param code
|
||||
* @param trouble
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public int updateState(CoupletTroubleCode code) {
|
||||
public int updEndTime(CoupletTroubleCode trouble) {
|
||||
// 查询表中最大时间
|
||||
List<CoupletTroubleCode> maxTime = sysTroubleMapper.selectMaxTime();
|
||||
// 然后将结束时间改成当前时间
|
||||
if (maxTime != null) {
|
||||
sysTroubleMapper.updEndTime(trouble);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -26,10 +26,11 @@
|
|||
<update id="cleanTroubleCode">
|
||||
truncate table couplet_trouble_code
|
||||
</update>
|
||||
<update id="updateState">
|
||||
update couplet_trouble_code set processing_state = 1 where thourble_id = #{troubleId}
|
||||
<update id="updEndTime">
|
||||
update couplet_trouble_code set trouble_end_time = #{troubleEndTime} where trouble_vin = #{troubleVin}
|
||||
</update>
|
||||
|
||||
|
||||
<select id="selectTroubleList" parameterType="com.couplet.business.server.mapper.SysTroubleMapper" resultMap="SysTroubleResult">
|
||||
<include refid="selectTroubleVo"/>
|
||||
<where>
|
||||
|
@ -45,5 +46,8 @@
|
|||
<select id="selectTroubleListByGrade" resultType="com.couplet.common.domain.CoupletTroubleGrade">
|
||||
select * from couplet_trouble_grade
|
||||
</select>
|
||||
<select id="selectMaxTime" resultType="com.couplet.common.domain.CoupletTroubleCode">
|
||||
select max(trouble_start_time) from couplet_trouble_code
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
|
Loading…
Reference in New Issue