|
@@ -13,6 +13,7 @@ import org.springblade.common.aspect.VendingLog;
|
|
|
import org.springblade.common.constant.CommonConstant;
|
|
|
import org.springblade.common.enums.FacilityStatusEnum;
|
|
|
import org.springblade.common.enums.OrderStateEnum;
|
|
|
+import org.springblade.common.enums.VargoWayStatusEnum;
|
|
|
import org.springblade.common.enums.VendingLogEnum;
|
|
|
import org.springblade.modules.api.request.VendingHeartReq;
|
|
|
import org.springblade.modules.api.request.VendingOrderReq;
|
|
@@ -21,9 +22,7 @@ import org.springblade.modules.api.response.VendingOrderGoodsRes;
|
|
|
import org.springblade.modules.api.response.VendingOrderRes;
|
|
|
import org.springblade.modules.api.service.VendingOrderService;
|
|
|
import org.springblade.modules.business.entity.Facility;
|
|
|
-import org.springblade.modules.business.entity.FacilityFault;
|
|
|
-import org.springblade.modules.business.enums.FacilityFaultStatusEnum;
|
|
|
-import org.springblade.modules.business.service.IFacilityFaultService;
|
|
|
+import org.springblade.modules.business.service.IFacilityCargoWayService;
|
|
|
import org.springblade.modules.business.service.IFacilityService;
|
|
|
import org.springblade.modules.finance.entity.Order;
|
|
|
import org.springblade.modules.finance.entity.OrderGoods;
|
|
@@ -58,7 +57,7 @@ public class ApiVendingController {
|
|
|
private final IOrderGoodsService orderGoodsService;
|
|
|
private final IOrderService orderService;
|
|
|
private final IFacilityService facilityService;
|
|
|
- private final IFacilityFaultService facilityFaultService;
|
|
|
+ private final IFacilityCargoWayService facilityCargoWayService;
|
|
|
|
|
|
|
|
|
@VendingLog(VendingLogEnum.ORDER)
|
|
@@ -169,6 +168,10 @@ public class ApiVendingController {
|
|
|
.set(OrderGoods::getShipment, 0)
|
|
|
.eq(OrderGoods::getId, req.getOrderGoodsId())
|
|
|
.update();
|
|
|
+
|
|
|
+ //将货道改为异常,该货道不可购买
|
|
|
+ facilityCargoWayService.updateCargoWayStatus(req.getMachineId(), req.getChannel(), VargoWayStatusEnum.FAULT);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -186,14 +189,23 @@ public class ApiVendingController {
|
|
|
facility.setHeartbeatTime(now);
|
|
|
if ("0".equals(req.getErrorNum()) || "OK".equals(req.getStatus())) {
|
|
|
facility.setFacilityStatus(FacilityStatusEnum.ON_LINE.getValue());
|
|
|
+
|
|
|
+ //将异常货道恢复
|
|
|
+ facilityCargoWayService.updateCargoWayStatus(String.valueOf(facility.getId()), null, VargoWayStatusEnum.NORMAL);
|
|
|
+
|
|
|
+ //位置校验
|
|
|
+ //"location": "N,22.97637,E,113.37804"
|
|
|
+ String[] split = req.getLocation().split(",");
|
|
|
+
|
|
|
+ //TODO 2024/9/26 LuoDLeo 位置过大,发短信提醒
|
|
|
+ //double distance = DistanceUtils.getDistance(Double.parseDouble(facility.getLongitude()), Double.parseDouble(facility.getLatitude()), Double.parseDouble(split[3]), Double.parseDouble(split[1]));
|
|
|
+
|
|
|
+ //更新位置
|
|
|
+ facility.setLatitude(split[1]);//纬度N
|
|
|
+ facility.setLongitude(split[3]);//经度E
|
|
|
+
|
|
|
facilityService.updateById(facility);
|
|
|
|
|
|
- FacilityFault facilityFault = new FacilityFault();
|
|
|
- facilityFault.setFacilityId(req.getMachineId());
|
|
|
- facilityFault.setFaultDesc(FacilityFaultStatusEnum.getDesc("0"));
|
|
|
- facilityFault.setFaultStatus("0");
|
|
|
- facilityFault.setCreateTime(now);
|
|
|
- facilityFaultService.save(facilityFault);
|
|
|
return;
|
|
|
} else {
|
|
|
//设备故障
|
|
@@ -203,16 +215,12 @@ public class ApiVendingController {
|
|
|
//录入故障信息
|
|
|
String[] split = req.getErrorArray().replace("{", "").replace("}", "").split(",");
|
|
|
|
|
|
- List<FacilityFault> facilityFaults = new ArrayList<>();
|
|
|
for (String status : split) {
|
|
|
- FacilityFault facilityFault = new FacilityFault();
|
|
|
- facilityFault.setFacilityId(req.getMachineId());
|
|
|
- facilityFault.setFaultDesc(FacilityFaultStatusEnum.getDesc(status));
|
|
|
- facilityFault.setFaultStatus(status);
|
|
|
- facilityFault.setCreateTime(now);
|
|
|
- facilityFaults.add(facilityFault);
|
|
|
+ //判断是不是货道异常,是的话将该货道设置为不可购买
|
|
|
+ if (status.startsWith("10")) {
|
|
|
+ facilityCargoWayService.updateCargoWayStatus(String.valueOf(facility.getId()), status.substring(2), VargoWayStatusEnum.FAULT);
|
|
|
+ }
|
|
|
}
|
|
|
- facilityFaultService.saveBatch(facilityFaults);
|
|
|
}
|
|
|
}
|
|
|
|