Commit 41df7676 authored by 喻训浩's avatar 喻训浩

fix: avi修改

parent fa2eaeac
......@@ -54,22 +54,22 @@ public class LedService {
//获得车辆区域进出车统计
List<CarStatisticsVO> sta = webStationCache.get("busSta", ArrayList.class);
/*if (CollectionUtils.isEmpty(sta))
return null;
for (CarStatisticsVO carStatisticsVO : sta) {
if (!carStatisticsVO.getAreaNo().equals(ledNo)) {
continue;
}
if (!carStatisticsVO.getDateType().equals(DateType.TODAY)) {
continue;
}
if (carStatisticsVO.getBusType().equals(BusType.IN)) {
vo.setBusIn(carStatisticsVO.getSize());
}
if (carStatisticsVO.getBusType().equals(BusType.OUT)) {
vo.setBusOut(carStatisticsVO.getSize());
if (!CollectionUtils.isEmpty(sta)) {
for (CarStatisticsVO carStatisticsVO : sta) {
if (!carStatisticsVO.getAreaNo().equals(ledNo)) {
continue;
}
if (!carStatisticsVO.getDateType().equals(DateType.TODAY)) {
continue;
}
if (carStatisticsVO.getBusType().equals(BusType.IN)) {
vo.setBusIn(carStatisticsVO.getSize());
}
if (carStatisticsVO.getBusType().equals(BusType.OUT)) {
vo.setBusOut(carStatisticsVO.getSize());
}
}
}*/
}
if (ledNo.equals("1") || ledNo.equals("2") || ledNo.equals("3") || ledNo.equals("4")) {
vo.setRoomInfoList(new ArrayList<>());
......
......@@ -211,7 +211,10 @@ public class AVIMonitorJob extends GatherJob {
if (null == ve) {
ve = vehicleCache.get(veKey, Vehicle.class);
}
vehicles.add(ve);
if (ve.getState() == false){
vehicles.add(ve);
}
}
Map<String, List<Vehicle>> veMap = vehicles.stream().filter(a -> a.getState() != false).collect(Collectors.groupingBy(Vehicle::getLane));
......@@ -255,6 +258,7 @@ public class AVIMonitorJob extends GatherJob {
PaintshopStation station = collect.get(i);
Skid skid = vehicle.getSkid();
vehicle.setSkid(null);
vehicle.setCurrentRfid(null);
Long laneId = station.getLaneId();
List<PaintshopStation> lands = new ArrayList<>();
......@@ -275,6 +279,9 @@ public class AVIMonitorJob extends GatherJob {
if (tem.getSkid() != null) {
tem2.setSkid(tem.getSkid());
tem2.setState(StationState.USE);
} else {
tem2.setSkid(null);
tem2.setState(StationState.FREE);
}
}
start.setSkid(skid);
......@@ -287,6 +294,9 @@ public class AVIMonitorJob extends GatherJob {
if (null != tem2.getSkid()) {
tem.setState(StationState.USE);
tem.setSkid(tem2.getSkid());
} else {
tem2.setSkid(null);
tem2.setState(StationState.FREE);
}
}
end.setState(StationState.USE);
......
......@@ -5,12 +5,15 @@ import net.vtstar.scada.base.gather.job.GatherJob;
import net.vtstar.zhongtong.avi.equipment.domain.PaintshopArea;
import net.vtstar.zhongtong.avi.equipment.domain.PaintshopStation;
import net.vtstar.zhongtong.avi.global.constant.Constant;
import net.vtstar.zhongtong.avi.monitoring.domain.Skid;
import net.vtstar.zhongtong.avi.monitoring.domain.Warning;
import net.vtstar.zhongtong.avi.monitoring.domain.enums.BusType;
import net.vtstar.zhongtong.avi.monitoring.domain.enums.DateType;
import net.vtstar.zhongtong.avi.monitoring.domain.enums.StationState;
import net.vtstar.zhongtong.avi.monitoring.domain.vo.CarStatisticsVO;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.boot.autoconfigure.validation.ValidationAutoConfiguration;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.stereotype.Component;
......@@ -64,7 +67,7 @@ public class RedisToCacheJob extends GatherJob {
warningCache.put(Constant.LED_PREFIX + key, warnings);
}
//处理工位信息
//处理进出车信息
Set<String> keys = redisTemplate.keys(Constant.STATION_PREFIX + "*");
List<PaintshopStation> stations = new ArrayList<>();
......@@ -83,11 +86,22 @@ public class RedisToCacheJob extends GatherJob {
addStatistics(today, vos, "0", DateType.TODAY);
addStatistics(previous, vos, "0", DateType.YESTERDAY);
//处理工位信息
List<PaintshopArea> areas = webStationCache.get("stationList", ArrayList.class);
for (PaintshopArea area : areas) {
Long id = area.getId();
List<PaintshopStation> stationList = listMap.get(id);
Map<String, PaintshopStation> collect = stationList.stream().collect(Collectors.toMap(PaintshopStation::getCode, sta -> sta, (key1, key2) -> key1));
for (Map.Entry<String, PaintshopStation> entry : collect.entrySet()) {
PaintshopStation value = entry.getValue();
Skid skid = value.getSkid();
if (null != skid){
value.setState(StationState.USE);
value.setBusNo(skid.getBusNo());
value.setBusType(skid.getBusType());
}
}
area.setStationMap(collect);
addStatistics(today, vos, area.getCode(), DateType.TODAY);
}
......@@ -105,12 +119,12 @@ public class RedisToCacheJob extends GatherJob {
Integer todaySize = (Integer) valueOperations.get(Constant.BUS_SIZE_IN + code + ":" + today);
vo.setDateType(dateType);
if (null == todaySize) {
if (code.equals("0")) {
vo.setSize(BigDecimal.valueOf(40));
} else {
// vo.setSize(BigDecimal.ZERO);
vo.setSize(BigDecimal.valueOf(10).add(new BigDecimal(r.nextInt(20))));
}
// if (code.equals("0")) {
// vo.setSize(BigDecimal.valueOf(40));
// } else {
vo.setSize(BigDecimal.ZERO);
// vo.setSize(BigDecimal.valueOf(10).add(new BigDecimal(r.nextInt(20))));
// }
} else {
vo.setSize(BigDecimal.valueOf(todaySize));
}
......@@ -121,12 +135,12 @@ public class RedisToCacheJob extends GatherJob {
Integer todayOut = (Integer) valueOperations.get(Constant.BUS_SIZE_OUT + code + ":" + today);
out.setDateType(dateType);
if (null == todayOut) {
if (code.equals("0")) {
out.setSize(BigDecimal.valueOf(40));
} else {
//out.setSize(BigDecimal.ZERO);
out.setSize(BigDecimal.valueOf(10).add(new BigDecimal(r.nextInt(20))));
}
// if (code.equals("0")) {
// out.setSize(BigDecimal.valueOf(40));
// } else {
out.setSize(BigDecimal.ZERO);
// out.setSize(BigDecimal.valueOf(10).add(new BigDecimal(r.nextInt(20))));
// }
} else {
out.setSize(BigDecimal.valueOf(todayOut));
}
......@@ -135,11 +149,4 @@ public class RedisToCacheJob extends GatherJob {
vos.add(vo);
vos.add(out);
}
public static void main(String[] args) {
Random r = new Random();
int i = r.nextInt(20);
System.out.println(i);
}
}
......@@ -82,13 +82,13 @@ public class ReadDataToCacheRunner implements CommandLineRunner {
warningCache.put(warning.getCode(), warning);
}
List<WorkRoom> rooms = workRoomMapper.findList(new WhereFilter(), WorkRoom.class);
Map<String, List<WorkRoom>> listMap = rooms.stream().collect(Collectors.groupingBy(WorkRoom::getLedNo));
for (Map.Entry<String, List<WorkRoom>> entry : listMap.entrySet()) {
roomCache.put(Constant.LED_PREFIX + entry.getKey(), entry.getValue());
}
// List<WorkRoom> rooms = workRoomMapper.findList(new WhereFilter(), WorkRoom.class);
//
//
// Map<String, List<WorkRoom>> listMap = rooms.stream().collect(Collectors.groupingBy(WorkRoom::getLedNo));
// for (Map.Entry<String, List<WorkRoom>> entry : listMap.entrySet()) {
// roomCache.put(Constant.LED_PREFIX + entry.getKey(), entry.getValue());
// }
List<PaintshopStation> stations = stationMapper.findList(new WhereFilter() {{
addJoin(PaintshopStation.class, "area_id", PaintshopArea.class, "id");
......@@ -127,7 +127,7 @@ public class ReadDataToCacheRunner implements CommandLineRunner {
// valueOperations.set(Constant.STATION_PREFIX + station.getCode() ,station);
}
Map<Long, List<PaintshopStation>> stationMap = stations.stream().filter(sta -> sta.getLaneCode() != null).collect(Collectors.groupingBy(PaintshopStation::getLaneId));
Map<Long, List<PaintshopStation>> stationMap = stations.stream().filter(sta -> sta.getLaneId() != null).collect(Collectors.groupingBy(PaintshopStation::getLaneId));
for (Map.Entry<Long, List<PaintshopStation>> entry : stationMap.entrySet()) {
laneStationCache.put(entry.getKey(), entry.getValue());
}
......
......@@ -125,7 +125,7 @@ public class RfidMessageHandler extends AbstractTesterMessageHandler {
String key = Constant.BUS_SIZE_IN + "0:" + format;
Integer size = (Integer) valueOperations.get(key);
if (null == size) {
size = 0;
size = 1;
}
valueOperations.set(key, size);
return;
......@@ -144,28 +144,39 @@ public class RfidMessageHandler extends AbstractTesterMessageHandler {
if (null != rfid && id.equals(rfid)) {
if (state == 1) {
Date occurTime = vehicle.getOccurTime();
long l = occurTime.getTime() - date.getTime() / 1000;
if (l < 60) {
log.error("{} 平移车发生重发现象 ,滑撬id {}", vehicleCode, id);
return;
if (null != occurTime) {
long l = (date.getTime() - occurTime.getTime()) / 1000;
if (l < 60) {
log.error("{} 平移车发生重发现象 ,滑撬id {}", vehicleCode, id);
return;
}
}
}
}
vehicle.setState(0 == state ? false : true);
if (state == 0) {
vehicle.setState(false);
valueOperations.set(Constant.VEHICLE_PREFIX + vehicleCode, vehicle);
return;
}
vehicle.setState(true);
vehicle.setOccurTime(date);
vehicle.setCurrentRfid(id);
vehicle.setSkid(skid);
valueOperations.set(Constant.VEHICLE_PREFIX + vehicleCode, vehicle);
// valueOperations.set(Constant.VEHICLE_PREFIX + vehicleCode, vehicle);
if (state == 0){
return;
}
List<PaintshopArea> areas = webStationCache.get("stationList", ArrayList.class);
for (PaintshopArea area : areas) {
Map<String, PaintshopStation> stationMap = area.getStationMap();
for (Map.Entry<String, PaintshopStation> entry : stationMap.entrySet()) {
PaintshopStation value = entry.getValue();
if (!value.getVehicleLaneCode().equals(vehicle.getLane())) {
continue;
}
if (value.getState().equals(StationState.FREE)) {
continue;
}
......@@ -184,35 +195,42 @@ public class RfidMessageHandler extends AbstractTesterMessageHandler {
if (start.getCode().equals(value.getCode())) {
vehicle.setSkid(start.getSkid());
vehicle.setCurrentRfid(start.getSkid().getRfid());
for (int j = 1; j < lands.size() - 2; j++) {
for (int j = 1; j < lands.size() - 1; j++) {
PaintshopStation tem = lands.get(j);
PaintshopStation tem2 = lands.get(j - 1);
if (tem.getSkid() != null) {
tem2.setSkid(tem.getSkid());
tem2.setState(StationState.USE);
} else {
tem2.setState(StationState.FREE);
tem2.setSkid(null);
}
}
} else if (end.getCode().equals(value.getCode())) {
vehicle.setSkid(end.getSkid());
vehicle.setCurrentRfid(start.getSkid().getRfid());
for (int j = lands.size() - 2; j > 0; j--) {
for (int j = lands.size() - 2; j >= 0; j--) {
PaintshopStation tem = lands.get(j);
PaintshopStation tem2 = lands.get(j + 1);
if (tem.getSkid() != null){
if (tem.getSkid() != null) {
tem2.setState(StationState.USE);
tem2.setSkid(tem.getSkid());
} else {
tem2.setState(StationState.FREE);
tem2.setSkid(null);
}
}
}
//记录过站信息
String areaCode = value.getAreaId().toString();
String areaKey = Constant.BUS_SIZE_IN + areaCode + ":" + today;
Integer size = (Integer) valueOperations.get(areaKey);
if (null == size) {
size = 0;
size = 1;
} else {
size++;
}
......
......@@ -39,6 +39,6 @@ spring.resources.static-locations=classpath:/META-INF/resources/,file:///D:/prod
# redis
#spring.redis.host=10.1.25.249
spring.redis.host=10.1.25.224
spring.redis.host=192.168.15.199
spring.redis.port=6379
spring.redis.password=
\ No newline at end of file
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