|
@@ -12,6 +12,7 @@ import com.java110.core.smo.hardwareAdapation.ICarBlackWhiteInnerServiceSMO;
|
|
|
import com.java110.core.smo.hardwareAdapation.ICarInoutInnerServiceSMO;
|
|
import com.java110.core.smo.hardwareAdapation.ICarInoutInnerServiceSMO;
|
|
|
import com.java110.core.smo.hardwareAdapation.IMachineInnerServiceSMO;
|
|
import com.java110.core.smo.hardwareAdapation.IMachineInnerServiceSMO;
|
|
|
import com.java110.core.smo.owner.IOwnerCarInnerServiceSMO;
|
|
import com.java110.core.smo.owner.IOwnerCarInnerServiceSMO;
|
|
|
|
|
+import com.java110.core.smo.parkingSpace.IParkingSpaceInnerServiceSMO;
|
|
|
import com.java110.dto.CommunityMemberDto;
|
|
import com.java110.dto.CommunityMemberDto;
|
|
|
import com.java110.dto.FeeConfigDto;
|
|
import com.java110.dto.FeeConfigDto;
|
|
|
import com.java110.dto.FeeDto;
|
|
import com.java110.dto.FeeDto;
|
|
@@ -19,6 +20,7 @@ import com.java110.dto.hardwareAdapation.CarBlackWhiteDto;
|
|
|
import com.java110.dto.hardwareAdapation.CarInoutDto;
|
|
import com.java110.dto.hardwareAdapation.CarInoutDto;
|
|
|
import com.java110.dto.hardwareAdapation.MachineDto;
|
|
import com.java110.dto.hardwareAdapation.MachineDto;
|
|
|
import com.java110.dto.owner.OwnerCarDto;
|
|
import com.java110.dto.owner.OwnerCarDto;
|
|
|
|
|
+import com.java110.dto.parking.ParkingSpaceDto;
|
|
|
import com.java110.entity.center.AppService;
|
|
import com.java110.entity.center.AppService;
|
|
|
import com.java110.event.service.api.ServiceDataFlowEvent;
|
|
import com.java110.event.service.api.ServiceDataFlowEvent;
|
|
|
import com.java110.utils.constant.BusinessTypeConstant;
|
|
import com.java110.utils.constant.BusinessTypeConstant;
|
|
@@ -38,6 +40,7 @@ import org.springframework.http.HttpMethod;
|
|
|
import org.springframework.http.HttpStatus;
|
|
import org.springframework.http.HttpStatus;
|
|
|
import org.springframework.http.ResponseEntity;
|
|
import org.springframework.http.ResponseEntity;
|
|
|
|
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
@@ -71,16 +74,17 @@ public class MachineGetFreeParkingSpaceListener extends BaseMachineListener {
|
|
|
private ICarInoutInnerServiceSMO carInoutInnerServiceSMOImpl;
|
|
private ICarInoutInnerServiceSMO carInoutInnerServiceSMOImpl;
|
|
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
|
- private ICarBlackWhiteInnerServiceSMO carBlackWhiteInnerServiceSMOImpl;
|
|
|
|
|
|
|
+ private IOwnerCarInnerServiceSMO carInnerServiceSMOImpl;
|
|
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
|
- private IOwnerCarInnerServiceSMO carInnerServiceSMOImpl;
|
|
|
|
|
|
|
+ private IParkingSpaceInnerServiceSMO parkingSpaceInnerServiceSMOImpl;
|
|
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private IFeeInnerServiceSMO feeInnerServiceSMOImpl;
|
|
private IFeeInnerServiceSMO feeInnerServiceSMOImpl;
|
|
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
|
- private IFeeConfigInnerServiceSMO feeConfigInnerServiceSMOImpl;
|
|
|
|
|
|
|
+ private IOwnerCarInnerServiceSMO ownerCarInnerServiceSMOImpl;
|
|
|
|
|
+
|
|
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private ICommunityInnerServiceSMO communityInnerServiceSMOImpl;
|
|
private ICommunityInnerServiceSMO communityInnerServiceSMOImpl;
|
|
@@ -90,7 +94,7 @@ public class MachineGetFreeParkingSpaceListener extends BaseMachineListener {
|
|
|
|
|
|
|
|
super.validateMachineHeader(event, reqJson);
|
|
super.validateMachineHeader(event, reqJson);
|
|
|
|
|
|
|
|
- Assert.hasKeyAndValue(reqJson, "carNum", "请求报文中未包含车牌号");
|
|
|
|
|
|
|
+ Assert.hasKeyAndValue(reqJson, "communityId", "请求报文中未包含小区信息");
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -98,498 +102,60 @@ public class MachineGetFreeParkingSpaceListener extends BaseMachineListener {
|
|
|
protected void doSoService(ServiceDataFlowEvent event, DataFlowContext context, JSONObject reqJson) {
|
|
protected void doSoService(ServiceDataFlowEvent event, DataFlowContext context, JSONObject reqJson) {
|
|
|
|
|
|
|
|
//JSONObject outParam = null;
|
|
//JSONObject outParam = null;
|
|
|
- ResponseEntity<String> responseEntity = null;
|
|
|
|
|
- Map<String, String> reqHeader = context.getRequestHeaders();
|
|
|
|
|
- String communityId = reqHeader.get("communityId");
|
|
|
|
|
- String machineCode = reqHeader.get("machinecode");
|
|
|
|
|
- HttpHeaders headers = new HttpHeaders();
|
|
|
|
|
- for (String key : reqHeader.keySet()) {
|
|
|
|
|
- if (key.toLowerCase().equals("content-length")) {
|
|
|
|
|
- continue;
|
|
|
|
|
- }
|
|
|
|
|
- headers.add(key, reqHeader.get(key));
|
|
|
|
|
- }
|
|
|
|
|
- //根据设备编码查询 设备信息
|
|
|
|
|
- MachineDto machineDto = new MachineDto();
|
|
|
|
|
- machineDto.setMachineCode(machineCode);
|
|
|
|
|
- machineDto.setCommunityId(communityId);
|
|
|
|
|
- List<MachineDto> machineDtos = machineInnerServiceSMOImpl.queryMachines(machineDto);
|
|
|
|
|
- if (machineDtos == null || machineDtos.size() < 1) {
|
|
|
|
|
- responseEntity = MachineResDataVo.getResData(MachineResDataVo.CODE_ERROR, "该设备【" + machineCode + "】未在该小区【" + communityId + "】注册");
|
|
|
|
|
- context.setResponseEntity(responseEntity);
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
- //设备方向
|
|
|
|
|
- String direction = machineDtos.get(0).getDirection();
|
|
|
|
|
-
|
|
|
|
|
- //进入
|
|
|
|
|
- if (MACHINE_DIRECTION_IN.equals(direction)) {
|
|
|
|
|
- dealCarIn(event, context, reqJson, machineDtos.get(0), communityId);
|
|
|
|
|
- } else {
|
|
|
|
|
- dealCarOut(event, context, reqJson, machineDtos.get(0), communityId);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ String communityId = reqJson.getString("communityId");
|
|
|
|
|
+
|
|
|
|
|
+ //查询出小区内车位状态为空闲的数量
|
|
|
|
|
+ ParkingSpaceDto parkingSpaceDto = new ParkingSpaceDto();
|
|
|
|
|
+ parkingSpaceDto.setCommunityId(communityId);
|
|
|
|
|
+ parkingSpaceDto.setState("F");
|
|
|
|
|
+ int freeParkingSpaceCount = parkingSpaceInnerServiceSMOImpl.queryParkingSpacesCount(parkingSpaceDto);
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * 车辆出场
|
|
|
|
|
- *
|
|
|
|
|
- * @param event
|
|
|
|
|
- * @param context
|
|
|
|
|
- * @param reqJson
|
|
|
|
|
- * @param machineDto
|
|
|
|
|
- * @param communityId
|
|
|
|
|
- */
|
|
|
|
|
- private void dealCarOut(ServiceDataFlowEvent event, DataFlowContext context, JSONObject reqJson, MachineDto machineDto, String communityId) {
|
|
|
|
|
-
|
|
|
|
|
- //首先查询是否车辆有进场
|
|
|
|
|
|
|
+
|
|
|
|
|
+ //查询出小区内的在场车辆
|
|
|
CarInoutDto carInoutDto = new CarInoutDto();
|
|
CarInoutDto carInoutDto = new CarInoutDto();
|
|
|
- carInoutDto.setStates(new String[]{"100300", "100400", "100600"});
|
|
|
|
|
carInoutDto.setCommunityId(communityId);
|
|
carInoutDto.setCommunityId(communityId);
|
|
|
- carInoutDto.setCarNum(reqJson.getString("carNum"));
|
|
|
|
|
|
|
+ carInoutDto.setStates(new String[]{"100300", "100400", "100600"});
|
|
|
List<CarInoutDto> carInoutDtos = carInoutInnerServiceSMOImpl.queryCarInouts(carInoutDto);
|
|
List<CarInoutDto> carInoutDtos = carInoutInnerServiceSMOImpl.queryCarInouts(carInoutDto);
|
|
|
-
|
|
|
|
|
- if (carInoutDtos == null || carInoutDtos.size() < 1) {//数据有问题, 直接出场
|
|
|
|
|
- context.setResponseEntity(MachineResDataVo.getResData(MachineResDataVo.CODE_SUCCESS, "数据有问题,未查到入场记录,直接放行"));
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- CarInoutDto tmpCarInoutDto = carInoutDtos.get(0);
|
|
|
|
|
- reqJson.put("inoutId", tmpCarInoutDto.getInoutId());
|
|
|
|
|
-
|
|
|
|
|
- if (!"100400".equals(tmpCarInoutDto.getState())) {
|
|
|
|
|
-
|
|
|
|
|
- dealCarOutIncomplete(event, context, reqJson, tmpCarInoutDto, machineDto);
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- //标识支付完成,检查是否为支付超时
|
|
|
|
|
-
|
|
|
|
|
- if (judgeCarOutTimeOut(event, context, reqJson, tmpCarInoutDto, machineDto)) {
|
|
|
|
|
- JSONObject data = computeHourAndMoney(tmpCarInoutDto.getCommunityId(), new Date(), reqJson.getDate("feeRestartTime"));
|
|
|
|
|
- context.setResponseEntity(MachineResDataVo.getResData(MachineResDataVo.CODE_ERROR, "支付已超时,请重新支付", data));
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- modifyCarInoutInfo(event, context, reqJson, tmpCarInoutDto, machineDto);
|
|
|
|
|
- ResponseEntity<String> responseEntity = context.getResponseEntity();
|
|
|
|
|
-
|
|
|
|
|
- if (responseEntity.getStatusCode() != HttpStatus.OK) {
|
|
|
|
|
- context.setResponseEntity(MachineResDataVo.getResData(MachineResDataVo.CODE_ERROR, "后台处理数据异常" + responseEntity.getBody()));
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
- context.setResponseEntity(MachineResDataVo.getResData(MachineResDataVo.CODE_SUCCESS, "成功"));
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * 判断车辆出场是否已经超时
|
|
|
|
|
- *
|
|
|
|
|
- * @param event
|
|
|
|
|
- * @param context
|
|
|
|
|
- * @param reqJson
|
|
|
|
|
- * @param tmpCarInoutDto
|
|
|
|
|
- * @param machineDto
|
|
|
|
|
- * @return
|
|
|
|
|
- */
|
|
|
|
|
- private boolean judgeCarOutTimeOut(ServiceDataFlowEvent event, DataFlowContext context, JSONObject reqJson, CarInoutDto tmpCarInoutDto, MachineDto machineDto) {
|
|
|
|
|
- CommunityMemberDto communityMemberDto = new CommunityMemberDto();
|
|
|
|
|
- communityMemberDto.setCommunityId(machineDto.getCommunityId());
|
|
|
|
|
- communityMemberDto.setMemberTypeCd(CommunityMemberTypeConstant.PROPERTY);
|
|
|
|
|
- List<CommunityMemberDto> communityMemberDtos = communityInnerServiceSMOImpl.getCommunityMembers(communityMemberDto);
|
|
|
|
|
- String storeId = "-1";
|
|
|
|
|
- if (communityMemberDtos != null && communityMemberDtos.size() > 0) {
|
|
|
|
|
- storeId = communityMemberDtos.get(0).getMemberId();
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- FeeDto feeDto = new FeeDto();
|
|
|
|
|
- feeDto.setCommunityId(machineDto.getCommunityId());
|
|
|
|
|
- feeDto.setPayerObjId(reqJson.getString("inoutId"));
|
|
|
|
|
- feeDto.setIncomeObjId(storeId);
|
|
|
|
|
- feeDto.setFeeTypeCd(FeeTypeConstant.FEE_TYPE_TEMP_DOWN_PARKING_SPACE);
|
|
|
|
|
- feeDto.setState("2009001");
|
|
|
|
|
- feeDto.setFeeFlag("2006012");
|
|
|
|
|
- List<FeeDto> feeDtos = feeInnerServiceSMOImpl.queryFees(feeDto);
|
|
|
|
|
-
|
|
|
|
|
- if (feeDtos == null || feeDtos.size() < 1) {
|
|
|
|
|
- return false;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- FeeDto tmpFeeDto = feeDtos.get(0);
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- long dffMin = new Date().getTime() - tmpFeeDto.getEndTime().getTime();
|
|
|
|
|
-
|
|
|
|
|
- if (dffMin < 15 * 1000 * 60) {
|
|
|
|
|
- return false;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- //重新插入 一条 收费记录 收费
|
|
|
|
|
-
|
|
|
|
|
- HttpHeaders header = new HttpHeaders();
|
|
|
|
|
- context.getRequestCurrentHeaders().put(CommonConstant.HTTP_ORDER_TYPE_CD, "D");
|
|
|
|
|
- JSONArray businesses = new JSONArray();
|
|
|
|
|
- AppService service = event.getAppService();
|
|
|
|
|
- //添加单元信息
|
|
|
|
|
- businesses.add(modifyCarInout(reqJson, context, tmpCarInoutDto, "100600", ""));
|
|
|
|
|
- businesses.add(addCarInoutFee(reqJson, context, tmpCarInoutDto.getCommunityId(), DateUtil.getFormatTimeString(tmpFeeDto.getEndTime(), DateUtil.DATE_FORMATE_STRING_A)));
|
|
|
|
|
- JSONObject paramInObj = super.restToCenterProtocol(businesses, context.getRequestCurrentHeaders());
|
|
|
|
|
- //将 rest header 信息传递到下层服务中去
|
|
|
|
|
- super.freshHttpHeader(header, context.getRequestCurrentHeaders());
|
|
|
|
|
- ResponseEntity<String> responseEntity = this.callService(context, service.getServiceCode(), paramInObj);
|
|
|
|
|
- context.setResponseEntity(responseEntity);
|
|
|
|
|
- reqJson.put("feeRestartTime", tmpFeeDto.getEndTime());
|
|
|
|
|
-
|
|
|
|
|
- return true;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * 处理车辆未完成支付出场处理
|
|
|
|
|
- *
|
|
|
|
|
- * @param event
|
|
|
|
|
- * @param context
|
|
|
|
|
- * @param tmpCarInoutDto
|
|
|
|
|
- * @param machineDto
|
|
|
|
|
- */
|
|
|
|
|
- private void dealCarOutIncomplete(ServiceDataFlowEvent event, DataFlowContext context, JSONObject reqJson, CarInoutDto tmpCarInoutDto, MachineDto machineDto) {
|
|
|
|
|
- //判断车辆是否在白名单中
|
|
|
|
|
- String carNum = reqJson.getString("carNum");
|
|
|
|
|
- CarBlackWhiteDto carBlackWhiteDto = new CarBlackWhiteDto();
|
|
|
|
|
- carBlackWhiteDto.setCommunityId(tmpCarInoutDto.getCommunityId());
|
|
|
|
|
- carBlackWhiteDto.setCarNum(carNum);
|
|
|
|
|
- carBlackWhiteDto.setBlackWhite(CAR_WHITE);
|
|
|
|
|
- int count = carBlackWhiteInnerServiceSMOImpl.queryCarBlackWhitesCount(carBlackWhiteDto);
|
|
|
|
|
- if (count > 0) {
|
|
|
|
|
- modifyCarInoutInfo(event, context, reqJson, tmpCarInoutDto, machineDto);
|
|
|
|
|
- context.setResponseEntity(MachineResDataVo.getResData(MachineResDataVo.CODE_SUCCESS, "白名单中直接放行"));
|
|
|
|
|
- return;
|
|
|
|
|
|
|
+ List<String> carNums = new ArrayList<>();
|
|
|
|
|
+ for (CarInoutDto tmpCarInoutDto : carInoutDtos) {
|
|
|
|
|
+ carNums.add(tmpCarInoutDto.getCarNum());
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- //判断车辆出租和出售 时间是否到期
|
|
|
|
|
OwnerCarDto ownerCarDto = new OwnerCarDto();
|
|
OwnerCarDto ownerCarDto = new OwnerCarDto();
|
|
|
- ownerCarDto.setCarNum(carNum);
|
|
|
|
|
- ownerCarDto.setCommunityId(tmpCarInoutDto.getCommunityId());
|
|
|
|
|
- List<OwnerCarDto> ownerCarDtos = carInnerServiceSMOImpl.queryOwnerCars(ownerCarDto);
|
|
|
|
|
- Date nowTime = new Date();
|
|
|
|
|
- if (ownerCarDtos != null && ownerCarDtos.size() > 0) {
|
|
|
|
|
- //这里获取最新的一条记录 我们认为 一个小区中一辆车不能同时有两个车位
|
|
|
|
|
- OwnerCarDto tmpOwnerCarDto = ownerCarDtos.get(0);
|
|
|
|
|
- FeeDto feeDto = new FeeDto();
|
|
|
|
|
- feeDto.setPayerObjId(tmpOwnerCarDto.getPsId());
|
|
|
|
|
- feeDto.setCommunityId(tmpCarInoutDto.getCommunityId());
|
|
|
|
|
- List<FeeDto> feeDtos = feeInnerServiceSMOImpl.queryFees(feeDto);
|
|
|
|
|
-
|
|
|
|
|
- FeeDto tmpFeeDto = feeDtos.get(0);
|
|
|
|
|
-
|
|
|
|
|
- Date endTime = tmpFeeDto.getEndTime();
|
|
|
|
|
-
|
|
|
|
|
- long betweenTime = (endTime.getTime() - nowTime.getTime());
|
|
|
|
|
-
|
|
|
|
|
- if (betweenTime > 0) {
|
|
|
|
|
- long day = betweenTime / (60 * 60 * 24 * 1000);
|
|
|
|
|
- JSONObject data = new JSONObject();
|
|
|
|
|
- data.put("day", day);//还剩余多少天
|
|
|
|
|
- modifyCarInoutInfo(event, context, reqJson, tmpCarInoutDto, machineDto, HIRE_SELL_OUT);
|
|
|
|
|
- context.setResponseEntity(MachineResDataVo.getResData(MachineResDataVo.CODE_SUCCESS, "成功", data));
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ ownerCarDto.setCommunityId(communityId);
|
|
|
|
|
+ ownerCarDto.setCarNums(carNums.toArray(new String[carNums.size()]));
|
|
|
|
|
+ List<OwnerCarDto> ownerCarDtos = ownerCarInnerServiceSMOImpl.queryOwnerCars(ownerCarDto);
|
|
|
|
|
|
|
|
- //计算缴费金额
|
|
|
|
|
- Date inTime = null;
|
|
|
|
|
- try {
|
|
|
|
|
- inTime = DateUtil.getDateFromString(tmpCarInoutDto.getInTime(), DateUtil.DATE_FORMATE_STRING_A);
|
|
|
|
|
- } catch (Exception e) {
|
|
|
|
|
- logger.error("格式化出错", e);
|
|
|
|
|
- context.setResponseEntity(MachineResDataVo.getResData(MachineResDataVo.CODE_ERROR, "后台异常,数据格式错误"));
|
|
|
|
|
- return;
|
|
|
|
|
|
|
+ List<String> psIds = new ArrayList<>();
|
|
|
|
|
+ for (OwnerCarDto tmpOwnerCarDto : ownerCarDtos) {
|
|
|
|
|
+ psIds.add(tmpOwnerCarDto.getPsId());
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- JSONObject data = computeHourAndMoney(tmpCarInoutDto.getCommunityId(), nowTime, inTime);
|
|
|
|
|
-
|
|
|
|
|
- context.setResponseEntity(MachineResDataVo.getResData(MachineResDataVo.CODE_ERROR, "车辆未支付,请先支付", data));
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- private JSONObject computeHourAndMoney(String communityId, Date nowTime, Date inTime) {
|
|
|
|
|
- FeeConfigDto feeConfigDto = new FeeConfigDto();
|
|
|
|
|
- feeConfigDto.setCommunityId(communityId);
|
|
|
|
|
- feeConfigDto.setFeeTypeCd(FeeTypeConstant.FEE_TYPE_TEMP_DOWN_PARKING_SPACE);
|
|
|
|
|
- List<FeeConfigDto> feeConfigDtos = feeConfigInnerServiceSMOImpl.queryFeeConfigs(feeConfigDto);
|
|
|
|
|
-
|
|
|
|
|
- FeeConfigDto tmpFeeConfigDto = feeConfigDtos.get(0);
|
|
|
|
|
- long diff = nowTime.getTime() - inTime.getTime();
|
|
|
|
|
- long nd = 1000 * 24 * 60 * 60;// 一天的毫秒数
|
|
|
|
|
- long nh = 1000 * 60 * 60;// 一小时的毫秒数
|
|
|
|
|
- long nm = 1000 * 60;// 一分钟的毫秒数
|
|
|
|
|
- double day = 0;
|
|
|
|
|
- double hour = 0;
|
|
|
|
|
- double min = 0;
|
|
|
|
|
- day = diff / nd;// 计算差多少天
|
|
|
|
|
- hour = diff % nd / nh + day * 24;// 计算差多少小时
|
|
|
|
|
- min = diff % nd % nh / nm + day * 24 * 60;// 计算差多少分钟
|
|
|
|
|
- double money = 0.00;
|
|
|
|
|
- double newHour = hour;
|
|
|
|
|
- if (min > 0) { //一小时超过
|
|
|
|
|
- newHour += 1;
|
|
|
|
|
- }
|
|
|
|
|
- if (newHour <= 2) {
|
|
|
|
|
- money = Double.parseDouble(tmpFeeConfigDto.getAdditionalAmount());
|
|
|
|
|
- } else {
|
|
|
|
|
- double lastHour = newHour - 2;
|
|
|
|
|
- money = lastHour * Double.parseDouble(tmpFeeConfigDto.getSquarePrice()) + Double.parseDouble(tmpFeeConfigDto.getAdditionalAmount());
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- JSONObject data = new JSONObject();
|
|
|
|
|
- data.put("money", money);//缴费金额
|
|
|
|
|
- data.put("hour", new Double(hour).intValue());//停车时间
|
|
|
|
|
- data.put("min", new Double(min).intValue());//停车时间
|
|
|
|
|
- return data;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- private void modifyCarInoutInfo(ServiceDataFlowEvent event, DataFlowContext context, JSONObject reqJson, CarInoutDto tmpCarInoutDto, MachineDto machineDto) {
|
|
|
|
|
- modifyCarInoutInfo(event, context, reqJson, tmpCarInoutDto, machineDto, "");
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- private void modifyCarInoutInfo(ServiceDataFlowEvent event, DataFlowContext context, JSONObject reqJson, CarInoutDto tmpCarInoutDto, MachineDto machineDto, String from) {
|
|
|
|
|
- HttpHeaders header = new HttpHeaders();
|
|
|
|
|
- context.getRequestCurrentHeaders().put(CommonConstant.HTTP_ORDER_TYPE_CD, "D");
|
|
|
|
|
- JSONArray businesses = new JSONArray();
|
|
|
|
|
- AppService service = event.getAppService();
|
|
|
|
|
- //添加单元信息
|
|
|
|
|
- businesses.add(modifyCarInout(reqJson, context, tmpCarInoutDto));
|
|
|
|
|
- reqJson.put("inoutId", tmpCarInoutDto.getInoutId());
|
|
|
|
|
- businesses.add(addCarInoutDetail(reqJson, context, tmpCarInoutDto.getCommunityId(), machineDto));
|
|
|
|
|
- if (HIRE_SELL_OUT.equals(from)) {
|
|
|
|
|
- JSONObject tmpModifyCarInoutFee = modifyCarInoutFee(reqJson, context, tmpCarInoutDto.getCommunityId(), machineDto);
|
|
|
|
|
- if (tmpModifyCarInoutFee != null) {
|
|
|
|
|
- businesses.add(tmpModifyCarInoutFee);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- JSONObject paramInObj = super.restToCenterProtocol(businesses, context.getRequestCurrentHeaders());
|
|
|
|
|
- //将 rest header 信息传递到下层服务中去
|
|
|
|
|
- super.freshHttpHeader(header, context.getRequestCurrentHeaders());
|
|
|
|
|
- ResponseEntity<String> responseEntity = this.callService(context, service.getServiceCode(), paramInObj);
|
|
|
|
|
- context.setResponseEntity(responseEntity);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- private JSONObject modifyCarInout(JSONObject reqJson, DataFlowContext context, CarInoutDto carInoutDto) {
|
|
|
|
|
- return modifyCarInout(reqJson, context, carInoutDto, "100500", DateUtil.getFormatTimeString(new Date(), DateUtil.DATE_FORMATE_STRING_A));
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- private JSONObject modifyCarInout(JSONObject reqJson, DataFlowContext context, CarInoutDto carInoutDto, String state, String endTime) {
|
|
|
|
|
- JSONObject business = JSONObject.parseObject("{\"datas\":{}}");
|
|
|
|
|
- business.put(CommonConstant.HTTP_BUSINESS_TYPE_CD, BusinessTypeConstant.BUSINESS_TYPE_UPDATE_CAR_INOUT);
|
|
|
|
|
- business.put(CommonConstant.HTTP_SEQ, DEFAULT_SEQ);
|
|
|
|
|
- business.put(CommonConstant.HTTP_INVOKE_MODEL, CommonConstant.HTTP_INVOKE_MODEL_S);
|
|
|
|
|
- JSONObject businessCarInout = new JSONObject();
|
|
|
|
|
- businessCarInout.putAll(BeanConvertUtil.beanCovertMap(carInoutDto));
|
|
|
|
|
- businessCarInout.put("state", state);
|
|
|
|
|
- businessCarInout.put("outTime", endTime);
|
|
|
|
|
- //计算 应收金额
|
|
|
|
|
- business.getJSONObject(CommonConstant.HTTP_BUSINESS_DATAS).put("businessCarInout", businessCarInout);
|
|
|
|
|
- return business;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * 处理车辆进入
|
|
|
|
|
- *
|
|
|
|
|
- * @param reqJson
|
|
|
|
|
- * @param machineDto
|
|
|
|
|
- * @param communityId
|
|
|
|
|
- */
|
|
|
|
|
- private void dealCarIn(ServiceDataFlowEvent event, DataFlowContext context, JSONObject reqJson, MachineDto machineDto, String communityId) {
|
|
|
|
|
- //车辆是否黑名单 车辆
|
|
|
|
|
- String carNum = reqJson.getString("carNum");
|
|
|
|
|
- CarBlackWhiteDto carBlackWhiteDto = new CarBlackWhiteDto();
|
|
|
|
|
- carBlackWhiteDto.setCommunityId(communityId);
|
|
|
|
|
- carBlackWhiteDto.setCarNum(carNum);
|
|
|
|
|
- carBlackWhiteDto.setBlackWhite(CAR_BLACK);
|
|
|
|
|
- int count = carBlackWhiteInnerServiceSMOImpl.queryCarBlackWhitesCount(carBlackWhiteDto);
|
|
|
|
|
- if (count > 0) {
|
|
|
|
|
- context.setResponseEntity(MachineResDataVo.getResData(MachineResDataVo.CODE_ERROR, carNum + "被加入黑名单,无法放行"));
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- HttpHeaders header = new HttpHeaders();
|
|
|
|
|
- context.getRequestCurrentHeaders().put(CommonConstant.HTTP_ORDER_TYPE_CD, "D");
|
|
|
|
|
- JSONArray businesses = new JSONArray();
|
|
|
|
|
-
|
|
|
|
|
- AppService service = event.getAppService();
|
|
|
|
|
-
|
|
|
|
|
- //添加单元信息
|
|
|
|
|
- businesses.add(addCarInout(reqJson, context, communityId));
|
|
|
|
|
- businesses.add(addCarInoutDetail(reqJson, context, communityId, machineDto));
|
|
|
|
|
- businesses.add(addCarInoutFee(reqJson, context, communityId));
|
|
|
|
|
-
|
|
|
|
|
- JSONObject paramInObj = super.restToCenterProtocol(businesses, context.getRequestCurrentHeaders());
|
|
|
|
|
-
|
|
|
|
|
- //将 rest header 信息传递到下层服务中去
|
|
|
|
|
- super.freshHttpHeader(header, context.getRequestCurrentHeaders());
|
|
|
|
|
-
|
|
|
|
|
- ResponseEntity<String> responseEntity = this.callService(context, service.getServiceCode(), paramInObj);
|
|
|
|
|
- if (responseEntity.getStatusCode() != HttpStatus.OK) {
|
|
|
|
|
- context.setResponseEntity(MachineResDataVo.getResData(MachineResDataVo.CODE_ERROR, responseEntity.getBody()));
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
- context.setResponseEntity(MachineResDataVo.getResData(MachineResDataVo.CODE_SUCCESS, "成功"));
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * 添加物业费用
|
|
|
|
|
- *
|
|
|
|
|
- * @param paramInJson 接口调用放传入入参
|
|
|
|
|
- * @param dataFlowContext 数据上下文
|
|
|
|
|
- * @return 订单服务能够接受的报文
|
|
|
|
|
- */
|
|
|
|
|
- private JSONObject addCarInoutFee(JSONObject paramInJson, DataFlowContext dataFlowContext, String communityId) {
|
|
|
|
|
- return addCarInoutFee(paramInJson, dataFlowContext, communityId, DateUtil.getNow(DateUtil.DATE_FORMATE_STRING_A));
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * 添加物业费用
|
|
|
|
|
- *
|
|
|
|
|
- * @param paramInJson 接口调用放传入入参
|
|
|
|
|
- * @param dataFlowContext 数据上下文
|
|
|
|
|
- * @return 订单服务能够接受的报文
|
|
|
|
|
- */
|
|
|
|
|
- private JSONObject addCarInoutFee(JSONObject paramInJson, DataFlowContext dataFlowContext, String communityId, String startTime) {
|
|
|
|
|
- CommunityMemberDto communityMemberDto = new CommunityMemberDto();
|
|
|
|
|
- communityMemberDto.setCommunityId(communityId);
|
|
|
|
|
- communityMemberDto.setMemberTypeCd(CommunityMemberTypeConstant.PROPERTY);
|
|
|
|
|
- List<CommunityMemberDto> communityMemberDtos = communityInnerServiceSMOImpl.getCommunityMembers(communityMemberDto);
|
|
|
|
|
- String storeId = "-1";
|
|
|
|
|
- if (communityMemberDtos != null && communityMemberDtos.size() > 0) {
|
|
|
|
|
- storeId = communityMemberDtos.get(0).getMemberId();
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- JSONObject business = JSONObject.parseObject("{\"datas\":{}}");
|
|
|
|
|
- business.put(CommonConstant.HTTP_BUSINESS_TYPE_CD, BusinessTypeConstant.BUSINESS_TYPE_SAVE_FEE_INFO);
|
|
|
|
|
- business.put(CommonConstant.HTTP_SEQ, DEFAULT_SEQ + 1);
|
|
|
|
|
- business.put(CommonConstant.HTTP_INVOKE_MODEL, CommonConstant.HTTP_INVOKE_MODEL_S);
|
|
|
|
|
- JSONObject businessUnit = new JSONObject();
|
|
|
|
|
- businessUnit.put("feeId", "-1");
|
|
|
|
|
- businessUnit.put("feeTypeCd", FeeTypeConstant.FEE_TYPE_TEMP_DOWN_PARKING_SPACE);
|
|
|
|
|
- businessUnit.put("incomeObjId", storeId);
|
|
|
|
|
- businessUnit.put("amount", "-1.00");
|
|
|
|
|
- businessUnit.put("startTime", startTime);
|
|
|
|
|
- businessUnit.put("endTime", DateUtil.getLastTime()); // 临时车将结束时间刷成2038年
|
|
|
|
|
- businessUnit.put("communityId", communityId);
|
|
|
|
|
- businessUnit.put("payerObjId", paramInJson.getString("inoutId"));
|
|
|
|
|
- businessUnit.put("feeFlag", "2006012"); // 一次性费用
|
|
|
|
|
- businessUnit.put("state", "2008001"); // 收费中
|
|
|
|
|
- businessUnit.put("userId", "-1");
|
|
|
|
|
- business.getJSONObject(CommonConstant.HTTP_BUSINESS_DATAS).put("businessFee", businessUnit);
|
|
|
|
|
-
|
|
|
|
|
- return business;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * 出租或出售 车辆出场
|
|
|
|
|
- *
|
|
|
|
|
- * @param reqJson
|
|
|
|
|
- * @param context
|
|
|
|
|
- * @param communityId
|
|
|
|
|
- * @param machineDto
|
|
|
|
|
- * @return
|
|
|
|
|
- */
|
|
|
|
|
- private JSONObject modifyCarInoutFee(JSONObject reqJson, DataFlowContext context, String communityId, MachineDto machineDto) {
|
|
|
|
|
-
|
|
|
|
|
- CommunityMemberDto communityMemberDto = new CommunityMemberDto();
|
|
|
|
|
- communityMemberDto.setCommunityId(communityId);
|
|
|
|
|
- communityMemberDto.setMemberTypeCd(CommunityMemberTypeConstant.PROPERTY);
|
|
|
|
|
- List<CommunityMemberDto> communityMemberDtos = communityInnerServiceSMOImpl.getCommunityMembers(communityMemberDto);
|
|
|
|
|
- String storeId = "-1";
|
|
|
|
|
- if (communityMemberDtos != null && communityMemberDtos.size() > 0) {
|
|
|
|
|
- storeId = communityMemberDtos.get(0).getMemberId();
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
FeeDto feeDto = new FeeDto();
|
|
FeeDto feeDto = new FeeDto();
|
|
|
feeDto.setCommunityId(communityId);
|
|
feeDto.setCommunityId(communityId);
|
|
|
- feeDto.setPayerObjId(reqJson.getString("inoutId"));
|
|
|
|
|
- feeDto.setIncomeObjId(storeId);
|
|
|
|
|
- feeDto.setFeeTypeCd(FeeTypeConstant.FEE_TYPE_TEMP_DOWN_PARKING_SPACE);
|
|
|
|
|
- feeDto.setState("2008001");
|
|
|
|
|
- feeDto.setFeeFlag("2006012");
|
|
|
|
|
- List<FeeDto> feeDtos = feeInnerServiceSMOImpl.queryFees(feeDto);
|
|
|
|
|
-
|
|
|
|
|
- if (feeDtos == null || feeDtos.size() < 1) {
|
|
|
|
|
- return null;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ feeDto.setPayerObjIds(psIds.toArray(new String[psIds.size()]));
|
|
|
|
|
+ feeDto.setNoArrearsEndTime(new Date());
|
|
|
|
|
+ int communityCarCount = feeInnerServiceSMOImpl.queryFeesCount(feeDto);
|
|
|
|
|
|
|
|
- FeeDto tmpFeeDto = feeDtos.get(0);
|
|
|
|
|
|
|
+ //不是 出租或出售 车辆数
|
|
|
|
|
+ int realCarCount = carInoutDtos.size() - communityCarCount;
|
|
|
|
|
|
|
|
- JSONObject business = JSONObject.parseObject("{\"datas\":{}}");
|
|
|
|
|
- business.put(CommonConstant.HTTP_BUSINESS_TYPE_CD, BusinessTypeConstant.BUSINESS_TYPE_UPDATE_FEE_INFO);
|
|
|
|
|
- business.put(CommonConstant.HTTP_SEQ, DEFAULT_SEQ + 1);
|
|
|
|
|
- business.put(CommonConstant.HTTP_INVOKE_MODEL, CommonConstant.HTTP_INVOKE_MODEL_S);
|
|
|
|
|
- JSONObject businessUnit = new JSONObject();
|
|
|
|
|
- businessUnit.putAll(BeanConvertUtil.beanCovertMap(tmpFeeDto));
|
|
|
|
|
- businessUnit.put("endTime", DateUtil.getNow(DateUtil.DATE_FORMATE_STRING_A));
|
|
|
|
|
- businessUnit.put("state", "2009001"); // 收费中
|
|
|
|
|
- business.getJSONObject(CommonConstant.HTTP_BUSINESS_DATAS).put("businessFee", businessUnit);
|
|
|
|
|
|
|
+ int realFreeParkingSpaceCount = freeParkingSpaceCount - realCarCount;
|
|
|
|
|
+ JSONObject realFreeParkingSpace = new JSONObject();
|
|
|
|
|
+ realFreeParkingSpace.put("total", freeParkingSpaceCount);
|
|
|
|
|
+ realFreeParkingSpace.put("freeCount", realFreeParkingSpaceCount);
|
|
|
|
|
|
|
|
- return business;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ context.setResponseEntity(MachineResDataVo.getResData(MachineResDataVo.CODE_SUCCESS, "成功", realFreeParkingSpace));
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * 添加小区信息
|
|
|
|
|
- *
|
|
|
|
|
- * @param paramInJson 接口调用放传入入参
|
|
|
|
|
- * @param dataFlowContext 数据上下文
|
|
|
|
|
- * @return 订单服务能够接受的报文
|
|
|
|
|
- */
|
|
|
|
|
- private JSONObject addCarInout(JSONObject paramInJson, DataFlowContext dataFlowContext, String communityId) {
|
|
|
|
|
-
|
|
|
|
|
- paramInJson.put("inoutId", GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_inoutId));
|
|
|
|
|
- JSONObject business = JSONObject.parseObject("{\"datas\":{}}");
|
|
|
|
|
- business.put(CommonConstant.HTTP_BUSINESS_TYPE_CD, BusinessTypeConstant.BUSINESS_TYPE_SAVE_CAR_INOUT);
|
|
|
|
|
- business.put(CommonConstant.HTTP_SEQ, DEFAULT_SEQ);
|
|
|
|
|
- business.put(CommonConstant.HTTP_INVOKE_MODEL, CommonConstant.HTTP_INVOKE_MODEL_S);
|
|
|
|
|
- JSONObject businessCarInout = new JSONObject();
|
|
|
|
|
- businessCarInout.put("carNum", paramInJson.getString("carNum"));
|
|
|
|
|
- businessCarInout.put("inoutId", paramInJson.getString("inoutId"));
|
|
|
|
|
- businessCarInout.put("communityId", communityId);
|
|
|
|
|
- businessCarInout.put("state", "100300");
|
|
|
|
|
- businessCarInout.put("inTime", DateUtil.getFormatTimeString(new Date(), DateUtil.DATE_FORMATE_STRING_A));
|
|
|
|
|
- //计算 应收金额
|
|
|
|
|
- business.getJSONObject(CommonConstant.HTTP_BUSINESS_DATAS).put("businessCarInout", businessCarInout);
|
|
|
|
|
- return business;
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * 添加小区信息
|
|
|
|
|
- *
|
|
|
|
|
- * @param paramInJson 接口调用放传入入参
|
|
|
|
|
- * @param dataFlowContext 数据上下文
|
|
|
|
|
- * @return 订单服务能够接受的报文
|
|
|
|
|
- */
|
|
|
|
|
- private JSONObject addCarInoutDetail(JSONObject paramInJson, DataFlowContext dataFlowContext, String communityId, MachineDto machineDto) {
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- JSONObject business = JSONObject.parseObject("{\"datas\":{}}");
|
|
|
|
|
- business.put(CommonConstant.HTTP_BUSINESS_TYPE_CD, BusinessTypeConstant.BUSINESS_TYPE_SAVE_CAR_INOUT);
|
|
|
|
|
- business.put(CommonConstant.HTTP_SEQ, DEFAULT_SEQ);
|
|
|
|
|
- business.put(CommonConstant.HTTP_INVOKE_MODEL, CommonConstant.HTTP_INVOKE_MODEL_S);
|
|
|
|
|
- JSONObject businessCarInoutDetail = new JSONObject();
|
|
|
|
|
- businessCarInoutDetail.put("carNum", paramInJson.getString("carNum"));
|
|
|
|
|
- businessCarInoutDetail.put("inoutId", paramInJson.getString("inoutId"));
|
|
|
|
|
- businessCarInoutDetail.put("communityId", communityId);
|
|
|
|
|
- businessCarInoutDetail.put("machineId", machineDto.getMachineId());
|
|
|
|
|
- businessCarInoutDetail.put("machineCode", machineDto.getMachineCode());
|
|
|
|
|
- businessCarInoutDetail.put("carInout", machineDto.getDirection());
|
|
|
|
|
- businessCarInoutDetail.put("detailId", "-1");
|
|
|
|
|
- //计算 应收金额
|
|
|
|
|
- business.getJSONObject(CommonConstant.HTTP_BUSINESS_DATAS).put("businessCarInoutDetail", businessCarInoutDetail);
|
|
|
|
|
- return business;
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public String getServiceCode() {
|
|
public String getServiceCode() {
|
|
|
- return ServiceCodeMachineTranslateConstant.MACHINE_ROAD_GATE_OPEN;
|
|
|
|
|
|
|
+ return ServiceCodeMachineTranslateConstant.MACHINE_GET_FREE_PARKING_SPACE;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public HttpMethod getHttpMethod() {
|
|
public HttpMethod getHttpMethod() {
|
|
|
- return HttpMethod.POST;
|
|
|
|
|
|
|
+ return HttpMethod.GET;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|