dev
parent
3c27bc3bc0
commit
06f860e11e
|
|
@ -43,115 +43,6 @@ import static com.njzscloud.supervisory.hsoa.pojo.param.PushProvincialUploadPara
|
|||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class HsoaService extends ServiceImpl<HsoaMapper, HsoaRecode> implements IService<HsoaRecode> {
|
||||
// private final OrderInfoService orderInfoService;
|
||||
/* private final TruckLocationTrackService truckLocationTrackService;
|
||||
private final AtomicBoolean run = new AtomicBoolean(false);
|
||||
private final AtomicInteger succ = new AtomicInteger(0);
|
||||
private final AtomicInteger fail = new AtomicInteger(0);
|
||||
private final AtomicInteger total = new AtomicInteger(0);
|
||||
private final AtomicLong order = new AtomicLong(0);
|
||||
|
||||
public synchronized Map<String, Object> pushOrder(Long orderId, Integer count) {
|
||||
MapBuilder<String, Object> builder = MapUtil.<String, Object>builder();
|
||||
|
||||
if (run.get()) {
|
||||
int i1 = total.get();
|
||||
int i2 = succ.get();
|
||||
int i3 = fail.get();
|
||||
long v = order.get();
|
||||
return builder
|
||||
.put("订单", v)
|
||||
.put("任务数量", i1)
|
||||
.put("成功数量", i2)
|
||||
.put("失败数量", i3)
|
||||
.put("剩余数量", i1 - i2 - i3)
|
||||
.build();
|
||||
}
|
||||
OrderPagingResult orderDetail = orderInfoService.detail(orderId);
|
||||
Assert.notNull(orderDetail, () -> Exceptions.clierr("订单不存在"));
|
||||
String licensePlate = orderDetail.getLicensePlate();
|
||||
String transCompanyName = orderDetail.getTransCompanyName();
|
||||
List<TruckLocationTrackEntity> list = truckLocationTrackService.list(Wrappers.<TruckLocationTrackEntity>lambdaQuery().eq(TruckLocationTrackEntity::getOrderId, orderId));
|
||||
|
||||
if (list.isEmpty()) {
|
||||
return builder
|
||||
.put("订单", orderId)
|
||||
.put("任务数量", 0)
|
||||
.build();
|
||||
}
|
||||
if (count == null || count == 0) {
|
||||
count = list.size();
|
||||
} else {
|
||||
count = Math.min(count, list.size());
|
||||
}
|
||||
run.set(true);
|
||||
order.set(orderId);
|
||||
total.set(count);
|
||||
succ.set(0);
|
||||
fail.set(0);
|
||||
int c = count;
|
||||
Thread thread = new Thread(() -> {
|
||||
for (int i = 0; i < c; i++) {
|
||||
ThreadUtil.sleep(1000);
|
||||
TruckLocationTrackEntity locationTrack = list.get(i);
|
||||
boolean b = run.get();
|
||||
if (!b) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
Double longitude = locationTrack.getLongitude();
|
||||
Double latitude = locationTrack.getLatitude();
|
||||
Double speed = locationTrack.getSpeed();
|
||||
Integer direction = locationTrack.getDirection();
|
||||
LocalDateTime locationTime = locationTrack.getLocationTime();
|
||||
String time = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").format(locationTime);
|
||||
HsoaResult<?> result = Hsoa.pushVehicleTrajectory(new PushVehicleTrajectoryParam()
|
||||
.setCompanyName(transCompanyName)
|
||||
.setTransportLicense(orderDetail.getCertificateSn())
|
||||
.setPlateNumber(licensePlate)
|
||||
.setVehicleType(orderDetail.getTruckCategory())
|
||||
.setLongitude(longitude + "")
|
||||
.setLatitude(latitude + "")
|
||||
.setSpeed(speed)
|
||||
.setDirection(direction + 0.0)
|
||||
.setStateType("正常行驶")
|
||||
.setAlarmType("无")
|
||||
.setLoadStatus("2")
|
||||
.setSealedStatus("1")
|
||||
.setLiftStatus("0")
|
||||
.setAccStatus(1)
|
||||
.setGpsTime(time)
|
||||
.setLocationMode("WGS84")
|
||||
);
|
||||
if (result == null || !result.isSuccess()) {
|
||||
fail.incrementAndGet();
|
||||
log.error("推送定位数据失败,数据Id:{}", locationTrack.getId());
|
||||
} else {
|
||||
succ.incrementAndGet();
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
fail.incrementAndGet();
|
||||
log.error("推送定位数据失败,数据Id:{}", locationTrack.getId(), e);
|
||||
}
|
||||
}
|
||||
run.set(false);
|
||||
});
|
||||
thread.setDaemon(true);
|
||||
thread.start();
|
||||
|
||||
int i1 = total.get();
|
||||
int i2 = succ.get();
|
||||
int i3 = fail.get();
|
||||
return builder
|
||||
.put("订单", orderId)
|
||||
.put("任务数量", i1)
|
||||
.put("成功数量", i2)
|
||||
.put("失败数量", i3)
|
||||
.put("剩余数量", i1 - i2 - i3)
|
||||
.build();
|
||||
|
||||
} */
|
||||
|
||||
public HsoaResult<?> pushProvincialSave(OrderPagingResult detail) {
|
||||
log.info("上传数据:{}", Jackson.toJsonStr(detail));
|
||||
|
|
@ -261,7 +152,7 @@ public class HsoaService extends ServiceImpl<HsoaMapper, HsoaRecode> implements
|
|||
.setTransportationEnterpriseId(detail.getTransCompanyId() == null ? null : detail.getTransCompanyId().toString())
|
||||
.setTransportationEnterpriseName(detail.getTransCompanyName())
|
||||
);
|
||||
log.info(Jackson.toJsonStr(param));
|
||||
// log.info(Jackson.toJsonStr(param));
|
||||
return Hsoa.pushProvincial(param);
|
||||
// return null;
|
||||
}
|
||||
|
|
@ -283,13 +174,13 @@ public class HsoaService extends ServiceImpl<HsoaMapper, HsoaRecode> implements
|
|||
.setUploadPath(uploadPath)
|
||||
);
|
||||
if (upload.isSuccess()) {
|
||||
log.info("图片:{}、{}", uploadPath, upload.getUrl());
|
||||
return upload.getUrl();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
log.error("上传失败", e);
|
||||
return null;
|
||||
} finally {
|
||||
IoUtil.close(in);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue