结束时间已实现

server_five_dongxiaodong
dongxiaodong 2024-04-11 18:29:57 +08:00
parent 81632a5679
commit 42da762c53
11 changed files with 56 additions and 31 deletions

View File

@ -8,6 +8,7 @@ import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
@FeignClient(contextId = "remoteTroubleService" , @FeignClient(contextId = "remoteTroubleService" ,
value = ServiceNameConstants.BUSINESS_SERVICE, value = ServiceNameConstants.BUSINESS_SERVICE,
fallbackFactory = RemoteTroubleFallbackFactory.class fallbackFactory = RemoteTroubleFallbackFactory.class
@ -22,4 +23,11 @@ public interface RemoteTroubleService {
@PostMapping("/trouble/newFaultData") @PostMapping("/trouble/newFaultData")
public Result<?> newFaultData(@RequestBody CoupletTroubleCode code); public Result<?> newFaultData(@RequestBody CoupletTroubleCode code);
/**
*
* @param trouble
* @return
*/
@PostMapping("/trouble/updEndTime")
public int updEndTime(@RequestBody CoupletTroubleCode trouble);
} }

View File

@ -8,6 +8,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory; import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
/** /**
* @author fufanrui * @author fufanrui
* @version 1.0 * @version 1.0
@ -26,9 +27,13 @@ public class RemoteTroubleFallbackFactory implements FallbackFactory<RemoteTroub
@Override @Override
public Result<?> newFaultData(CoupletTroubleCode code) { public Result<?> newFaultData(CoupletTroubleCode code) {
return Result.error("调用失败...."+cause.getMessage()); return Result.error("调用失败...." + cause.getMessage());
} }
@Override
public int updEndTime(CoupletTroubleCode trouble) {
return 0;
}
}; };
} }
} }

View File

@ -1,6 +1,5 @@
package com.couplet.analyze.msg.service.impl; package com.couplet.analyze.msg.service.impl;
import com.alibaba.fastjson.JSON;
import com.couplet.analyze.common.contents.AnalyzeEventContents; import com.couplet.analyze.common.contents.AnalyzeEventContents;
import com.couplet.analyze.msg.contents.StateConstant; import com.couplet.analyze.msg.contents.StateConstant;
import com.couplet.analyze.msg.domain.CoupletMsgData; import com.couplet.analyze.msg.domain.CoupletMsgData;
@ -85,10 +84,11 @@ public class BreakdownServiceImpl extends KeyExpirationEventMessageListener impl
// log.info("故障事件检测结束....."); // log.info("故障事件检测结束.....");
}else { }else {
long timeMillis = System.currentTimeMillis(); long timeMillis = System.currentTimeMillis();
Date date = MsgUtils.convertMillisToDateTimeSering(timeMillis);
CoupletTroubleCode troubleCode = new CoupletTroubleCode(); CoupletTroubleCode troubleCode = new CoupletTroubleCode();
troubleCode.setTroubleEndTime(date); troubleCode.setTroubleEndTime(new Date());
log.info("故障事件结束时间:"+date); troubleCode.setTroubleVin(coupletMsgData.getVin());
remoteTroubleService.updEndTime(troubleCode);
log.info("故障事件结束时间:"+timeMillis);
log.info("故障事件结束....."); log.info("故障事件结束.....");
} }
} }

View File

@ -49,7 +49,7 @@ public class ElectronicFenceServiceImpl implements IncidentService {
log.info("电子围栏事件redis存在......."); log.info("电子围栏事件redis存在.......");
for (Fence fence : cacheSet) { for (Fence fence : cacheSet) {
String fenceLongitudeLatitude = fence.getFenceLongitudeLatitude(); String fenceLongitudeLatitude = fence.getFenceLongitudeLatitude();
if (StringUtils.isEmpty(fenceLongitudeLatitude)){ if (!StringUtils.isEmpty(fenceLongitudeLatitude)){
/** /**
* *
*/ */

View File

@ -8,7 +8,6 @@ import java.nio.charset.StandardCharsets;
import java.time.Instant; import java.time.Instant;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.ZoneId; import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@ -23,18 +22,14 @@ import java.util.Random;
@Slf4j @Slf4j
public class MsgUtils { public class MsgUtils {
/** public static Date convertMillisToDate(long millis) {
*
* @return
*/
public static Date convertMillisToDateTimeSering(Long millis) {
Instant instant = Instant.ofEpochMilli(millis); Instant instant = Instant.ofEpochMilli(millis);
LocalDateTime localDateTime = LocalDateTime.ofInstant(instant, ZoneId.systemDefault()); LocalDateTime localDateTime = LocalDateTime.ofInstant(instant, ZoneId.systemDefault());
return Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant()); return Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant());
} }
/*** /**
* * GTA
* @return * @return
*/ */
public static String generateGTA() { public static String generateGTA() {

View File

@ -18,13 +18,13 @@ import java.util.regex.Pattern;
public class Main { public class Main {
public static void main(String[] args) { public static void main(String[] args) {
long timeMillis = System.currentTimeMillis(); long timeMillis = System.currentTimeMillis();
Date dateTime = convertMillisToDate(timeMillis); Date date = new Date(timeMillis);
System.out.println("Date Time: " + dateTime); System.out.println(date);
} }
private static Date convertMillisToDate(long millis) { // private static Date convertMillisToDate(long millis) {
Instant instant = Instant.ofEpochMilli(millis); // Instant instant = Instant.ofEpochMilli(millis);
LocalDateTime localDateTime = LocalDateTime.ofInstant(instant, ZoneId.systemDefault()); // LocalDateTime localDateTime = LocalDateTime.ofInstant(instant, ZoneId.systemDefault());
return Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant()); // return Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant());
} // }
} }

View File

@ -14,6 +14,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.Date;
import java.util.List; import java.util.List;
/** /**
@ -97,9 +98,9 @@ public class SysTroubleController extends BaseController {
/** /**
* *
*/ */
@PostMapping("/getUpdState") @PostMapping("/updEndTime")
public Result<?> getUpdState(@RequestBody CoupletTroubleCode code) { public int updEndTime(@RequestBody CoupletTroubleCode trouble) {
int updateState = troubleService.updateState(code); int i = troubleService.updEndTime(trouble);
return Result.success(updateState); return i;
} }
} }

View File

@ -6,7 +6,9 @@ import com.couplet.common.domain.CoupletTroubleGrade;
import com.couplet.common.domain.request.TroubleResp; import com.couplet.common.domain.request.TroubleResp;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.Date;
import java.util.List; import java.util.List;
/** /**
@ -30,5 +32,7 @@ public interface SysTroubleMapper extends BaseMapper<CoupletTroubleCode> {
void cleanTroubleCode(); void cleanTroubleCode();
int updateState(CoupletTroubleCode code); int updEndTime(CoupletTroubleCode trouble);
List<CoupletTroubleCode> selectMaxTime();
} }

View File

@ -6,6 +6,7 @@ import com.couplet.common.domain.CoupletTroubleCode;
import com.couplet.common.domain.CoupletTroubleGrade; import com.couplet.common.domain.CoupletTroubleGrade;
import com.couplet.common.domain.request.TroubleResp; import com.couplet.common.domain.request.TroubleResp;
import java.util.Date;
import java.util.List; import java.util.List;
/** /**
@ -27,5 +28,5 @@ public interface SysTroubleService extends IService<CoupletTroubleCode> {
void cleanTroubleCode(); void cleanTroubleCode();
int updateState(CoupletTroubleCode code); int updEndTime(CoupletTroubleCode trouble);
} }

View File

@ -12,6 +12,7 @@ import com.github.pagehelper.PageInfo;
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 java.util.Date;
import java.util.List; import java.util.List;
/** /**
@ -60,11 +61,17 @@ public class SysTroubleServiceImpl extends ServiceImpl<SysTroubleMapper, Couplet
/** /**
* *
* @param code * @param trouble
* @return * @return
*/ */
@Override @Override
public int updateState(CoupletTroubleCode code) { public int updEndTime(CoupletTroubleCode trouble) {
// 查询表中最大时间
List<CoupletTroubleCode> maxTime = sysTroubleMapper.selectMaxTime();
// 然后将结束时间改成当前时间
if (maxTime != null) {
sysTroubleMapper.updEndTime(trouble);
}
return 0; return 0;
} }

View File

@ -26,10 +26,11 @@
<update id="cleanTroubleCode"> <update id="cleanTroubleCode">
truncate table couplet_trouble_code truncate table couplet_trouble_code
</update> </update>
<update id="updateState"> <update id="updEndTime">
update couplet_trouble_code set processing_state = 1 where thourble_id = #{troubleId} update couplet_trouble_code set trouble_end_time = #{troubleEndTime} where trouble_vin = #{troubleVin}
</update> </update>
<select id="selectTroubleList" parameterType="com.couplet.business.server.mapper.SysTroubleMapper" resultMap="SysTroubleResult"> <select id="selectTroubleList" parameterType="com.couplet.business.server.mapper.SysTroubleMapper" resultMap="SysTroubleResult">
<include refid="selectTroubleVo"/> <include refid="selectTroubleVo"/>
<where> <where>
@ -45,5 +46,8 @@
<select id="selectTroubleListByGrade" resultType="com.couplet.common.domain.CoupletTroubleGrade"> <select id="selectTroubleListByGrade" resultType="com.couplet.common.domain.CoupletTroubleGrade">
select * from couplet_trouble_grade select * from couplet_trouble_grade
</select> </select>
<select id="selectMaxTime" resultType="com.couplet.common.domain.CoupletTroubleCode">
select max(trouble_start_time) from couplet_trouble_code
</select>
</mapper> </mapper>