| | |
| | | import com.java110.core.annotation.Java110Cmd; |
| | | import com.java110.core.annotation.Java110Transactional; |
| | | import com.java110.core.context.ICmdDataFlowContext; |
| | | import com.java110.core.event.cmd.AbstractServiceCmdListener; |
| | | import com.java110.core.event.cmd.Cmd; |
| | | import com.java110.core.event.cmd.CmdEvent; |
| | | import com.java110.core.factory.GenerateCodeFactory; |
| | | import com.java110.dto.CommunityMemberDto; |
| | | import com.java110.dto.fee.FeeAttrDto; |
| | | import com.java110.dto.fee.FeeConfigDto; |
| | | import com.java110.dto.fee.FeeDto; |
| | | import com.java110.dto.machine.CarBlackWhiteDto; |
| | | import com.java110.dto.machine.CarInoutDetailDto; |
| | | import com.java110.dto.machine.CarInoutDto; |
| | | import com.java110.dto.machine.MachineDto; |
| | | import com.java110.dto.owner.OwnerCarDto; |
| | | import com.java110.dto.owner.OwnerDto; |
| | | import com.java110.dto.parkingBoxArea.ParkingBoxAreaDto; |
| | | import com.java110.dto.tempCarFeeConfig.TempCarFeeConfigDto; |
| | | import com.java110.intf.common.ICarInoutDetailV1InnerServiceSMO; |
| | | import com.java110.intf.common.ICarInoutPaymentV1InnerServiceSMO; |
| | | import com.java110.intf.common.ICarInoutV1InnerServiceSMO; |
| | | import com.java110.intf.common.IMachineInnerServiceSMO; |
| | | import com.java110.intf.community.ICommunityInnerServiceSMO; |
| | | import com.java110.intf.community.IParkingBoxAreaV1InnerServiceSMO; |
| | | import com.java110.intf.fee.IFeeAttrInnerServiceSMO; |
| | | import com.java110.intf.fee.IFeeDetailInnerServiceSMO; |
| | | import com.java110.intf.fee.IFeeInnerServiceSMO; |
| | | import com.java110.intf.fee.ITempCarFeeConfigInnerServiceSMO; |
| | | import com.java110.intf.user.IBuildingOwnerV1InnerServiceSMO; |
| | | import com.java110.intf.user.ICarBlackWhiteV1InnerServiceSMO; |
| | | import com.java110.intf.user.IOwnerCarInnerServiceSMO; |
| | | import com.java110.intf.user.IOwnerCarV1InnerServiceSMO; |
| | | import com.java110.po.car.CarInoutDetailPo; |
| | |
| | | import com.java110.po.car.OwnerCarPo; |
| | | import com.java110.po.carInoutPayment.CarInoutPaymentPo; |
| | | import com.java110.po.fee.FeeAttrPo; |
| | | import com.java110.po.fee.PayFeeDetailPo; |
| | | import com.java110.po.fee.PayFeePo; |
| | | import com.java110.po.owner.OwnerPo; |
| | | import com.java110.utils.exception.CmdException; |
| | |
| | | * // modify by 张三 at 2021-09-12 第10行在某种场景下存在某种bug 需要修复,注释10至20行 加入 20行至30行 |
| | | */ |
| | | @Java110Cmd(serviceCode = "machineTranslate.machineUploadCarLog") |
| | | public class MachineUploadCarLogCmd extends AbstractServiceCmdListener { |
| | | public class MachineUploadCarLogCmd extends Cmd { |
| | | |
| | | public static final int CAR_TYPE_MONTH = 0; //月租车 |
| | | public static final int CAR_TYPE_MONTH = 1001; //月租车 |
| | | public static final int CAR_TYPE_SUB = 1; //成员车辆 |
| | | public static final int CAR_TYPE_TEMP = 2; //临时车辆 |
| | | public static final int CAR_TYPE_NO_DATA = 3; //没有数据 |
| | | public static final int CAR_TYPE_TEMP = 1003; //临时车辆 |
| | | public static final String CAR_TYPE_NO_DATA = "3"; //没有数据 |
| | | |
| | | public static final String TEMP_CAR_OWNER = "临时车车主"; |
| | | |
| | |
| | | @Autowired |
| | | private ICarInoutPaymentV1InnerServiceSMO carInoutPaymentV1InnerServiceSMOImpl; |
| | | |
| | | @Autowired |
| | | private IFeeDetailInnerServiceSMO feeDetailInnerServiceSMOImpl; |
| | | |
| | | @Autowired |
| | | private IParkingBoxAreaV1InnerServiceSMO parkingBoxAreaV1InnerServiceSMOImpl; |
| | | |
| | | @Autowired |
| | | private ICarBlackWhiteV1InnerServiceSMO carBlackWhiteV1InnerServiceSMOImpl; |
| | | |
| | | @Override |
| | | public void validate(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) { |
| | | Assert.hasKeyAndValue(reqJson, "machineCode", "必填,请填写设备编码"); |
| | |
| | | public void doCmd(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) throws CmdException { |
| | | |
| | | //是否是临时车 |
| | | int tempCar = CAR_TYPE_MONTH; |
| | | String tempCar = OwnerCarDto.LEASE_TYPE_TEMP; |
| | | String tempCarName ="临时车"; |
| | | |
| | | |
| | | //查询设备信息 |
| | | MachineDto machineDto = new MachineDto(); |
| | | machineDto.setMachineCode(reqJson.getString("machineCode")); |
| | | machineDto.setCommunityId(reqJson.getString("communityId")); |
| | | machineDto.setMachineTypeCd(MachineDto.MACHINE_TYPE_CAR); |
| | | List<MachineDto> machineDtos = machineInnerServiceSMOImpl.queryMachines(machineDto); |
| | | |
| | | Assert.listOnlyOne(machineDtos, "设备不存在"); |
| | |
| | | //说明是临时车 |
| | | if (ownerCarDtos == null || ownerCarDtos.size() == 0) { |
| | | tempCar = CAR_TYPE_NO_DATA; |
| | | tempCarName = "临时车"; |
| | | } else { |
| | | reqJson.put("carId", ownerCarDtos.get(0).getCarId()); |
| | | if (OwnerCarDto.CAR_TYPE_TEMP.equals(ownerCarDtos.get(0).getCarTypeCd())) { |
| | | tempCar = CAR_TYPE_TEMP; |
| | | tempCar = ownerCarDtos.get(0).getLeaseType(); |
| | | tempCarName = ownerCarDtos.get(0).getLeaseTypeName(); |
| | | if(ownerCarDtos.size()>1){ |
| | | for(OwnerCarDto tmpOwnerCarDto : ownerCarDtos){ |
| | | if(OwnerCarDto.LEASE_TYPE_TEMP.equals(tmpOwnerCarDto.getLeaseType())){ |
| | | continue; |
| | | } |
| | | tempCar = tmpOwnerCarDto.getLeaseType(); |
| | | tempCarName = tmpOwnerCarDto.getLeaseTypeName(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | //进场处理 |
| | | if (MachineDto.DIRECTION_IN.equals(machineDtos.get(0).getDirection())) { |
| | | carIn(reqJson, machineDtos.get(0), tempCar); |
| | | carIn(reqJson, machineDtos.get(0), tempCar,tempCarName); |
| | | } else { |
| | | carOut(reqJson, machineDtos.get(0), tempCar); |
| | | carOut(reqJson, machineDtos.get(0), tempCar,tempCarName); |
| | | } |
| | | |
| | | } |
| | |
| | | * @param machineDto |
| | | * @param tempCar |
| | | */ |
| | | private void carOut(JSONObject reqJson, MachineDto machineDto, int tempCar) { |
| | | private void carOut(JSONObject reqJson, MachineDto machineDto, String tempCar,String tempCarName) { |
| | | |
| | | String state = CarInoutDto.STATE_OUT; |
| | | //进场失败记录 |
| | | if (reqJson.containsKey("state") && "5".equals(reqJson.getString("state"))) { |
| | | state = CarInoutDto.STATE_IN_FAIL; |
| | | } |
| | | |
| | | |
| | | String paId = ""; |
| | | if (MachineDto.MACHINE_TYPE_CAR.equals(machineDto.getMachineTypeCd())) { |
| | | ParkingBoxAreaDto parkingBoxAreaDto = new ParkingBoxAreaDto(); |
| | | parkingBoxAreaDto.setBoxId(machineDto.getLocationObjId()); |
| | | parkingBoxAreaDto.setDefaultArea(ParkingBoxAreaDto.DEFAULT_AREA_TRUE); |
| | | List<ParkingBoxAreaDto> parkingBoxAreaDtos = parkingBoxAreaV1InnerServiceSMOImpl.queryParkingBoxAreas(parkingBoxAreaDto); |
| | | if (parkingBoxAreaDtos == null || parkingBoxAreaDtos.size() < 1) { |
| | | throw new CmdException("岗亭未配置停车场" + machineDto.getLocationObjId()); |
| | | } |
| | | paId = parkingBoxAreaDtos.get(0).getPaId(); |
| | | } |
| | | |
| | | CarInoutDto carInoutDto = new CarInoutDto(); |
| | | carInoutDto.setCommunityId(reqJson.getString("communityId")); |
| | | carInoutDto.setCarNum(reqJson.getString("carNum")); |
| | | carInoutDto.setPaId(machineDto.getLocationObjId()); |
| | | carInoutDto.setPaId(paId); |
| | | carInoutDto.setStates(new String[]{ |
| | | CarInoutDto.STATE_IN, |
| | | CarInoutDto.STATE_PAY, |
| | |
| | | }); |
| | | List<CarInoutDto> carInoutDtos = carInoutV1InnerServiceSMOImpl.queryCarInouts(carInoutDto); |
| | | |
| | | // 没有进场记录 |
| | | if (carInoutDtos == null || carInoutDtos.size() < 1) { |
| | | //可能车辆异常情况 没有 进场 记录 补一条 carInout |
| | | CarInoutPo carInoutPo = new CarInoutPo(); |
| | | carInoutPo.setCarNum(reqJson.getString("carNum")); |
| | | carInoutPo.setCommunityId(reqJson.getString("communityId")); |
| | | carInoutPo.setInoutId(GenerateCodeFactory.getGeneratorId(CODE_PREFIX_ID)); |
| | | carInoutPo.setInTime(reqJson.getString("outTime")); |
| | | carInoutPo.setState(CarInoutDto.STATE_IN); |
| | | carInoutPo.setPaId(machineDto.getLocationObjId()); |
| | | int flag = carInoutV1InnerServiceSMOImpl.saveCarInout(carInoutPo); |
| | | //可能车辆异常情况 没有 进场 补充进场记录 |
| | | reqJson.put("inTime", reqJson.getString("outTime")); |
| | | //carIn(reqJson, machineDto, tempCar); |
| | | //保存出场明细 |
| | | CarInoutDetailPo carInoutDetailPo = new CarInoutDetailPo(); |
| | | carInoutDetailPo.setCarInout(CarInoutDetailDto.CAR_INOUT_OUT); |
| | | carInoutDetailPo.setCarNum(reqJson.getString("carNum")); |
| | | carInoutDetailPo.setCommunityId(reqJson.getString("communityId")); |
| | | carInoutDetailPo.setDetailId(GenerateCodeFactory.getGeneratorId(CODE_PREFIX_ID)); |
| | | carInoutDetailPo.setInoutId("-1"); |
| | | carInoutDetailPo.setMachineCode(machineDto.getMachineCode()); |
| | | carInoutDetailPo.setMachineId(machineDto.getMachineId()); |
| | | carInoutDetailPo.setPaId(paId); |
| | | carInoutDetailPo.setRemark(reqJson.getString("remark")); |
| | | carInoutDetailPo.setState(state); |
| | | carInoutDetailPo.setCarType(CAR_TYPE_NO_DATA.equals(tempCar) ? OwnerCarDto.LEASE_TYPE_TEMP + "" : tempCar + ""); |
| | | carInoutDetailPo.setCarTypeName(CAR_TYPE_NO_DATA.equals(tempCar) ? "临时车" : tempCarName); |
| | | int flag = carInoutDetailV1InnerServiceSMOImpl.saveCarInoutDetail(carInoutDetailPo); |
| | | if (flag < 1) { |
| | | throw new CmdException("出场保存记录失败"); |
| | | throw new CmdException("保存出记录明细失败"); |
| | | } |
| | | carInoutDtos = carInoutV1InnerServiceSMOImpl.queryCarInouts(carInoutDto); |
| | | //出场失败了 |
| | | if (CarInoutDto.STATE_IN_FAIL.equals(state)) { |
| | | return; |
| | | } |
| | | } |
| | | |
| | | //保存出场明细 |
| | |
| | | carInoutDetailPo.setInoutId(carInoutDtos.get(0).getInoutId()); |
| | | carInoutDetailPo.setMachineCode(machineDto.getMachineCode()); |
| | | carInoutDetailPo.setMachineId(machineDto.getMachineId()); |
| | | carInoutDetailPo.setPaId(machineDto.getLocationObjId()); |
| | | carInoutDetailPo.setPaId(carInoutDtos.get(0).getPaId()); |
| | | carInoutDetailPo.setRemark(reqJson.getString("remark")); |
| | | carInoutDetailPo.setPhotoJpg(reqJson.getString("photoJpg")); |
| | | carInoutDetailPo.setState(state); |
| | | if(CAR_TYPE_NO_DATA.equals(tempCar)){ |
| | | carInoutDetailPo.setCarType(OwnerCarDto.LEASE_TYPE_TEMP); |
| | | carInoutDetailPo.setCarTypeName("临时车"); |
| | | //检查是否为黑白名单 |
| | | CarBlackWhiteDto carBlackWhiteDto = new CarBlackWhiteDto(); |
| | | carBlackWhiteDto.setCarNum(reqJson.getString("carNum")); |
| | | carBlackWhiteDto.setPaId(carInoutDtos.get(0).getPaId()); |
| | | carBlackWhiteDto.setValidity("Y"); |
| | | List<CarBlackWhiteDto> carBlackWhiteDtos = carBlackWhiteV1InnerServiceSMOImpl.queryCarBlackWhites(carBlackWhiteDto); |
| | | if(carBlackWhiteDtos != null && carBlackWhiteDtos.size() >0 ){ |
| | | if(CarBlackWhiteDto.BLACK_WHITE_BLACK.equals(carBlackWhiteDtos.get(0).getBlackWhite())){ |
| | | carInoutDetailPo.setCarType("B"); |
| | | carInoutDetailPo.setCarTypeName("黑名单"); |
| | | }else{ |
| | | carInoutDetailPo.setCarType("W"); |
| | | carInoutDetailPo.setCarTypeName("白名单"); |
| | | } |
| | | } |
| | | }else{ |
| | | carInoutDetailPo.setCarType(tempCar); |
| | | carInoutDetailPo.setCarTypeName(tempCarName); |
| | | } |
| | | int flag = carInoutDetailV1InnerServiceSMOImpl.saveCarInoutDetail(carInoutDetailPo); |
| | | |
| | | if (flag < 1) { |
| | | throw new CmdException("保存出记录明细失败"); |
| | | } |
| | | |
| | | //出场失败了 |
| | | if (CarInoutDto.STATE_IN_FAIL.equals(state)) { |
| | | return; |
| | | } |
| | | |
| | | //将状态更新为 出场状态 |
| | |
| | | } |
| | | |
| | | //写支付记录 |
| | | CarInoutPaymentPo carInoutPaymentPo = new CarInoutPaymentPo(); |
| | | carInoutPaymentPo.setPaymentId(GenerateCodeFactory.getGeneratorId("10")); |
| | | carInoutPaymentPo.setCommunityId(carInoutDtos.get(0).getCommunityId()); |
| | | carInoutPaymentPo.setInoutId(carInoutDtos.get(0).getInoutId()); |
| | | carInoutPaymentPo.setPaId(carInoutDtos.get(0).getPaId()); |
| | | carInoutPaymentPo.setPayCharge(reqJson.getString("payCharge")); |
| | | carInoutPaymentPo.setPayType(reqJson.getString("payType")); |
| | | carInoutPaymentPo.setRealCharge(reqJson.getString("realCharge")); |
| | | flag = carInoutPaymentV1InnerServiceSMOImpl.saveCarInoutPayment(carInoutPaymentPo); |
| | | if (flag < 1) { |
| | | throw new CmdException("更新出场时间失败"); |
| | | } |
| | | // CarInoutPaymentPo carInoutPaymentPo = new CarInoutPaymentPo(); |
| | | // carInoutPaymentPo.setPaymentId(GenerateCodeFactory.getGeneratorId("10")); |
| | | // carInoutPaymentPo.setCommunityId(carInoutDtos.get(0).getCommunityId()); |
| | | // carInoutPaymentPo.setInoutId(carInoutDtos.get(0).getInoutId()); |
| | | // carInoutPaymentPo.setPaId(carInoutDtos.get(0).getPaId()); |
| | | // carInoutPaymentPo.setPayCharge(reqJson.getString("payCharge")); |
| | | // carInoutPaymentPo.setPayType(reqJson.getString("payType")); |
| | | // carInoutPaymentPo.setRealCharge(reqJson.getString("realCharge")); |
| | | // flag = carInoutPaymentV1InnerServiceSMOImpl.saveCarInoutPayment(carInoutPaymentPo); |
| | | // if (flag < 1) { |
| | | // throw new CmdException("更新出场时间失败"); |
| | | // } |
| | | // |
| | | // //月租车 |
| | | // if (tempCar != CAR_TYPE_NO_DATA && tempCar != CAR_TYPE_TEMP) { |
| | | // return; |
| | | // } |
| | | // |
| | | // //如果有费用 则缴费 |
| | | // boolean hasFee = hasFeeAndPayFee(carInoutDtos.get(0), reqJson, carInoutPo, carInoutPaymentPo); |
| | | // |
| | | // double realCharge = Double.parseDouble(carInoutPaymentPo.getRealCharge()); |
| | | // |
| | | // //有费用 或者 缴费为0 时结束 |
| | | // if (hasFee || realCharge == 0) { |
| | | // return; |
| | | // } |
| | | // // 判断是否存在 临时车 虚拟业主 |
| | | // OwnerDto ownerDto = new OwnerDto(); |
| | | // ownerDto.setCommunityId(reqJson.getString("communityId")); |
| | | // ownerDto.setOwnerTypeCd(OwnerDto.OWNER_TYPE_CD_OWNER); |
| | | // ownerDto.setOwnerFlag(OwnerDto.OWNER_FLAG_FALSE); |
| | | // ownerDto.setName(TEMP_CAR_OWNER); |
| | | // List<OwnerDto> ownerDtos = buildingOwnerV1InnerServiceSMOImpl.queryBuildingOwners(ownerDto); |
| | | // if (ownerDtos == null || ownerDtos.size() < 1) { |
| | | // return; |
| | | // } |
| | | // JSONObject paramIn = new JSONObject(); |
| | | // paramIn.put("inTime", carInoutDtos.get(0).getInTime()); |
| | | // paramIn.put("carId", reqJson.getString("carId")); |
| | | // paramIn.put("communityId", carInoutDtos.get(0).getCommunityId()); |
| | | // paramIn.put("inoutId", carInoutDtos.get(0).getInoutId()); |
| | | // paramIn.put("ownerId", ownerDtos.get(0).getMemberId()); |
| | | // saveTempCarFee(paramIn, machineDto); |
| | | // |
| | | // //再去缴费 |
| | | // hasFeeAndPayFee(carInoutDtos.get(0), reqJson, carInoutPo, carInoutPaymentPo); |
| | | } |
| | | |
| | | //月租车 |
| | | if (tempCar != CAR_TYPE_NO_DATA && tempCar != CAR_TYPE_TEMP) { |
| | | return; |
| | | } |
| | | private boolean hasFeeAndPayFee(CarInoutDto carInoutDto, JSONObject reqJson, CarInoutPo carInoutPo, CarInoutPaymentPo carInoutPaymentPo) { |
| | | |
| | | //临时车时查看 是否有费用没有结束,可能是半小时免费 问题 或者时 其他原因 将费用结束 |
| | | FeeAttrDto feeAttrDto = new FeeAttrDto(); |
| | | feeAttrDto.setCommunityId(carInoutPo.getCommunityId()); |
| | | feeAttrDto.setSpecCd(FeeAttrDto.SPEC_CD_CAR_INOUT_ID); |
| | | feeAttrDto.setValue(carInoutPo.getInoutId()); |
| | | feeAttrDto.setCommunityId(carInoutDtos.get(0).getCommunityId()); |
| | | List<FeeAttrDto> feeAttrDtos = feeAttrInnerServiceSMOImpl.queryFeeAttrs(feeAttrDto); |
| | | |
| | | if (feeAttrDtos == null || feeAttrDtos.size() < 1) { |
| | | return; |
| | | } |
| | | FeeDto feeDto = new FeeDto(); |
| | | feeDto.setCommunityId(carInoutDtos.get(0).getCommunityId()); |
| | | feeDto.setFeeId(feeAttrDtos.get(0).getFeeId()); |
| | | feeDto.setState(FeeDto.STATE_DOING); |
| | | List<FeeDto> feeDtos = feeInnerServiceSMOImpl.queryFees(feeDto); |
| | | feeAttrDto.setState(FeeDto.STATE_DOING); |
| | | List<FeeDto> feeDtos = feeInnerServiceSMOImpl.queryFeeByAttr(feeAttrDto); |
| | | if (feeDtos == null || feeDtos.size() < 1) { |
| | | return; |
| | | return false; |
| | | } |
| | | PayFeePo payFeePo = new PayFeePo(); |
| | | payFeePo.setState(FeeDto.STATE_FINISH); |
| | | payFeePo.setFeeId(feeDtos.get(0).getFeeId()); |
| | | payFeePo.setEndTime(carInoutPo.getOutTime()); |
| | | payFeePo.setCommunityId(feeDtos.get(0).getCommunityId()); |
| | | flag = feeInnerServiceSMOImpl.updateFee(payFeePo); |
| | | int flag = feeInnerServiceSMOImpl.updateFee(payFeePo); |
| | | if (flag < 1) { |
| | | throw new CmdException("更新出场时间失败"); |
| | | throw new CmdException("更新费用失败"); |
| | | } |
| | | |
| | | |
| | | PayFeeDetailPo payFeeDetailPo = new PayFeeDetailPo(); |
| | | payFeeDetailPo.setDetailId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_detailId)); |
| | | payFeeDetailPo.setPrimeRate("1.00"); |
| | | FeeDto feeDto = feeDtos.get(0); |
| | | payFeeDetailPo.setStartTime(DateUtil.getFormatTimeString(feeDto.getStartTime(), DateUtil.DATE_FORMATE_STRING_A)); |
| | | payFeeDetailPo.setEndTime(carInoutPo.getOutTime()); |
| | | payFeeDetailPo.setCommunityId(carInoutDto.getCommunityId()); |
| | | payFeeDetailPo.setCycles("1"); |
| | | payFeeDetailPo.setReceivableAmount(carInoutPaymentPo.getPayCharge()); |
| | | payFeeDetailPo.setReceivedAmount(carInoutPaymentPo.getRealCharge()); |
| | | payFeeDetailPo.setFeeId(feeDto.getFeeId()); |
| | | |
| | | flag = feeDetailInnerServiceSMOImpl.saveFeeDetail(payFeeDetailPo); |
| | | if (flag < 1) { |
| | | throw new CmdException("更新费用失败"); |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | |
| | | * @param machineDto |
| | | * @param tempCar |
| | | */ |
| | | private void carIn(JSONObject reqJson, MachineDto machineDto, int tempCar) { |
| | | private void carIn(JSONObject reqJson, MachineDto machineDto, String tempCar,String tempCarName) { |
| | | String state = CarInoutDto.STATE_IN; |
| | | //进场失败记录 |
| | | if (reqJson.containsKey("state") && "5".equals(reqJson.getString("state"))) { |
| | | state = CarInoutDto.STATE_IN_FAIL; |
| | | } |
| | | |
| | | String paId = machineDto.getLocationObjId(); |
| | | |
| | | if (MachineDto.MACHINE_TYPE_CAR.equals(machineDto.getMachineTypeCd())) { |
| | | ParkingBoxAreaDto parkingBoxAreaDto = new ParkingBoxAreaDto(); |
| | | parkingBoxAreaDto.setBoxId(machineDto.getLocationObjId()); |
| | | parkingBoxAreaDto.setDefaultArea(ParkingBoxAreaDto.DEFAULT_AREA_TRUE); |
| | | List<ParkingBoxAreaDto> parkingBoxAreaDtos = parkingBoxAreaV1InnerServiceSMOImpl.queryParkingBoxAreas(parkingBoxAreaDto); |
| | | if (parkingBoxAreaDtos == null || parkingBoxAreaDtos.size() < 1) { |
| | | throw new CmdException("岗亭未配置停车场" + machineDto.getLocationObjId()); |
| | | } |
| | | paId = parkingBoxAreaDtos.get(0).getPaId(); |
| | | } |
| | | |
| | | //保存 |
| | | CarInoutPo carInoutPo = new CarInoutPo(); |
| | | carInoutPo.setCarNum(reqJson.getString("carNum")); |
| | | carInoutPo.setCommunityId(reqJson.getString("communityId")); |
| | | carInoutPo.setInoutId(GenerateCodeFactory.getGeneratorId(CODE_PREFIX_ID)); |
| | | carInoutPo.setInTime(reqJson.getString("inTime")); |
| | | carInoutPo.setState(CarInoutDto.STATE_IN); |
| | | carInoutPo.setPaId(machineDto.getLocationObjId()); |
| | | carInoutPo.setState(state); |
| | | carInoutPo.setPaId(paId); |
| | | int flag = carInoutV1InnerServiceSMOImpl.saveCarInout(carInoutPo); |
| | | |
| | | if (flag < 1) { |
| | |
| | | carInoutDetailPo.setInoutId(carInoutPo.getInoutId()); |
| | | carInoutDetailPo.setMachineCode(machineDto.getMachineCode()); |
| | | carInoutDetailPo.setMachineId(machineDto.getMachineId()); |
| | | carInoutDetailPo.setPaId(machineDto.getLocationObjId()); |
| | | carInoutDetailPo.setPaId(paId); |
| | | carInoutDetailPo.setState(state); |
| | | carInoutDetailPo.setRemark(reqJson.getString("remark")); |
| | | carInoutDetailPo.setPhotoJpg(reqJson.getString("photoJpg")); |
| | | if(CAR_TYPE_NO_DATA.equals(tempCar)){ |
| | | carInoutDetailPo.setCarType(OwnerCarDto.LEASE_TYPE_TEMP); |
| | | carInoutDetailPo.setCarTypeName("临时车"); |
| | | //检查是否为黑白名单 |
| | | CarBlackWhiteDto carBlackWhiteDto = new CarBlackWhiteDto(); |
| | | carBlackWhiteDto.setCarNum(reqJson.getString("carNum")); |
| | | carBlackWhiteDto.setPaId(paId); |
| | | carBlackWhiteDto.setValidity("Y"); |
| | | List<CarBlackWhiteDto> carBlackWhiteDtos = carBlackWhiteV1InnerServiceSMOImpl.queryCarBlackWhites(carBlackWhiteDto); |
| | | if(carBlackWhiteDtos != null && carBlackWhiteDtos.size() >0 ){ |
| | | if(CarBlackWhiteDto.BLACK_WHITE_BLACK.equals(carBlackWhiteDtos.get(0).getBlackWhite())){ |
| | | carInoutDetailPo.setCarType("B"); |
| | | carInoutDetailPo.setCarTypeName("黑名单"); |
| | | }else{ |
| | | carInoutDetailPo.setCarType("W"); |
| | | carInoutDetailPo.setCarTypeName("白名单"); |
| | | } |
| | | } |
| | | }else{ |
| | | carInoutDetailPo.setCarType(tempCar); |
| | | carInoutDetailPo.setCarTypeName(tempCarName); |
| | | } |
| | | flag = carInoutDetailV1InnerServiceSMOImpl.saveCarInoutDetail(carInoutDetailPo); |
| | | |
| | | if (flag < 1) { |
| | | throw new CmdException("保存入记录明细失败"); |
| | | } |
| | | //月租车 |
| | | if (tempCar != CAR_TYPE_NO_DATA && tempCar != CAR_TYPE_TEMP) { |
| | | if (!OwnerCarDto.LEASE_TYPE_TEMP.equals(carInoutDetailPo.getCarType())) { |
| | | return; |
| | | } |
| | | |
| | |
| | | } else { |
| | | reqJson.put("ownerId", ownerDtos.get(0).getMemberId()); |
| | | } |
| | | if (tempCar == CAR_TYPE_NO_DATA) { |
| | | if (CAR_TYPE_NO_DATA.equals(tempCar)) { |
| | | saveTempCar(reqJson, machineDto); |
| | | } |
| | | |
| | | //创建费用 |
| | | TempCarFeeConfigDto tempCarFeeConfigDto = new TempCarFeeConfigDto(); |
| | | tempCarFeeConfigDto.setCommunityId(reqJson.getString("communityId")); |
| | | tempCarFeeConfigDto.setPaId(machineDto.getLocationObjId()); |
| | | |
| | | List<TempCarFeeConfigDto> tempCarFeeConfigDtos = tempCarFeeConfigInnerServiceSMOImpl.queryTempCarFeeConfigs(tempCarFeeConfigDto); |
| | | |
| | | if (tempCarFeeConfigDtos == null || tempCarFeeConfigDtos.size() < 1) { // 停车场未配置收费规则 则不创建费用 |
| | | return; |
| | | } |
| | | |
| | | saveTempCarFee(reqJson, machineDto, tempCarFeeConfigDtos.get(0)); |
| | | saveTempCarFee(reqJson, machineDto); |
| | | } |
| | | |
| | | /** |
| | |
| | | * |
| | | * @param reqJson |
| | | * @param machineDto |
| | | * @param tempCarFeeConfigDto |
| | | */ |
| | | private void saveTempCarFee(JSONObject reqJson, MachineDto machineDto, TempCarFeeConfigDto tempCarFeeConfigDto) { |
| | | private void saveTempCarFee(JSONObject reqJson, MachineDto machineDto) { |
| | | |
| | | //创建费用 |
| | | TempCarFeeConfigDto tempCarFeeConfigDto = new TempCarFeeConfigDto(); |
| | | tempCarFeeConfigDto.setCommunityId(reqJson.getString("communityId")); |
| | | tempCarFeeConfigDto.setPaId(machineDto.getLocationObjId()); |
| | | List<TempCarFeeConfigDto> tempCarFeeConfigDtos = tempCarFeeConfigInnerServiceSMOImpl.queryTempCarFeeConfigs(tempCarFeeConfigDto); |
| | | |
| | | if (tempCarFeeConfigDtos == null || tempCarFeeConfigDtos.size() < 1) { // 停车场未配置收费规则 则不创建费用 |
| | | return; |
| | | } |
| | | |
| | | CommunityMemberDto communityMemberDto = new CommunityMemberDto(); |
| | | communityMemberDto.setCommunityId(reqJson.getString("communityId")); |
| | | communityMemberDto.setMemberTypeCd(CommunityMemberDto.MEMBER_TYPE_PROPERTY); |
| | |
| | | ownerCarPo.setRemark("临时车 物联网同步"); |
| | | ownerCarPo.setStartTime(DateUtil.getNow(DateUtil.DATE_FORMATE_STRING_A)); |
| | | ownerCarPo.setUserId("-1"); |
| | | ownerCarPo.setLeaseType(OwnerCarDto.LEASE_TYPE_TEMP); |
| | | int flag = ownerCarV1InnerServiceSMOImpl.saveOwnerCar(ownerCarPo); |
| | | |
| | | if (flag < 1) { |
| | |
| | | } |
| | | |
| | | reqJson.put("carId", ownerCarPo.getCarId()); |
| | | |
| | | |
| | | } |
| | | } |