| | |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.java110.core.annotation.Java110Cmd; |
| | | import com.java110.core.context.DataFlowContext; |
| | | import com.java110.core.annotation.Java110Transactional; |
| | | import com.java110.core.context.ICmdDataFlowContext; |
| | | import com.java110.core.event.cmd.Cmd; |
| | | import com.java110.core.event.cmd.CmdEvent; |
| | |
| | | import com.java110.dto.owner.OwnerCarDto; |
| | | import com.java110.dto.parking.ParkingSpaceDto; |
| | | import com.java110.dto.visit.VisitDto; |
| | | import com.java110.intf.common.ICarBlackWhiteInnerServiceSMO; |
| | | import com.java110.intf.common.IFileInnerServiceSMO; |
| | | import com.java110.intf.common.IFileRelInnerServiceSMO; |
| | | import com.java110.intf.community.IParkingSpaceInnerServiceSMO; |
| | | import com.java110.intf.community.IVisitInnerServiceSMO; |
| | | import com.java110.intf.community.IVisitV1InnerServiceSMO; |
| | | import com.java110.intf.user.ICarBlackWhiteV1InnerServiceSMO; |
| | | import com.java110.intf.user.IOwnerCarAttrInnerServiceSMO; |
| | | import com.java110.intf.user.IOwnerCarInnerServiceSMO; |
| | | import com.java110.intf.user.IOwnerCarV1InnerServiceSMO; |
| | | import com.java110.po.car.CarBlackWhitePo; |
| | | import com.java110.po.car.OwnerCarPo; |
| | | import com.java110.po.file.FileRelPo; |
| | | import com.java110.po.owner.VisitPo; |
| | | import com.java110.po.ownerCarAttr.OwnerCarAttrPo; |
| | | import com.java110.po.parking.ParkingSpacePo; |
| | | import com.java110.utils.constant.BusinessTypeConstant; |
| | | import com.java110.utils.exception.CmdException; |
| | | import com.java110.utils.util.Assert; |
| | | import com.java110.utils.util.BeanConvertUtil; |
| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.http.ResponseEntity; |
| | | |
| | | import java.beans.SimpleBeanInfo; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Calendar; |
| | | import java.util.Date; |
| | |
| | | private IVisitV1InnerServiceSMO visitV1InnerServiceSMOImpl; |
| | | |
| | | @Autowired |
| | | private IFileInnerServiceSMO fileInnerServiceSMOImpl; |
| | | |
| | | @Autowired |
| | | private IFileRelInnerServiceSMO fileRelInnerServiceSMOImpl; |
| | | |
| | | @Autowired |
| | |
| | | @Autowired |
| | | private IOwnerCarInnerServiceSMO ownerCarInnerServiceSMOImpl; |
| | | |
| | | @Autowired |
| | | private IFileInnerServiceSMO fileInnerServiceSMOImpl; |
| | | |
| | | @Autowired |
| | | private ICarBlackWhiteV1InnerServiceSMO carBlackWhiteV1InnerServiceSMOImpl; |
| | | |
| | | //键 |
| | | public static final String IS_NEED_REVIEW = "IS_NEED_REVIEW"; |
| | | |
| | |
| | | //键 |
| | | public static final String ASCRIPTION_CAR_AREA_ID = "ASCRIPTION_CAR_AREA_ID"; |
| | | |
| | | public static final String CODE_PREFIX_ID = "10"; |
| | | |
| | | @Override |
| | | public void validate(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException { |
| | | Assert.hasKeyAndValue(reqJson, "vName", "必填,请填写访客姓名"); |
| | | Assert.hasKeyAndValue(reqJson, "visitGender", "必填,请填写访客姓名"); |
| | | Assert.hasKeyAndValue(reqJson, "phoneNumber", "必填,请填写访客联系方式"); |
| | | Assert.hasKeyAndValue(reqJson, "visitTime", "必填,请填写访客拜访时间"); |
| | | |
| | | } |
| | | |
| | | @Override |
| | | @Java110Transactional |
| | | public void doCmd(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException { |
| | | |
| | | String userId = context.getReqHeaders().get("user-id"); |
| | | |
| | | reqJson.put("vId", GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_vId)); |
| | | //是否需要审核 |
| | | String isNeedReviewFlag = CommunitySettingFactory.getValue(reqJson.getString("communityId"), IS_NEED_REVIEW); |
| | |
| | | newTime.setTime(time); |
| | | newTime.add(Calendar.MINUTE, Integer.parseInt(freeTime));//日期加上分钟 |
| | | Date newDate = newTime.getTime(); |
| | | String finishFreeTime = DateUtil.getFormatTimeString(newDate,DateUtil.DATE_FORMATE_STRING_A); |
| | | String finishFreeTime = DateUtil.getFormatTimeString(newDate, DateUtil.DATE_FORMATE_STRING_A); |
| | | reqJson.put("freeTime", finishFreeTime); |
| | | if (!StringUtils.isEmpty(isNeedReviewFlag) && isNeedReviewFlag.equals("false")) { //不需要审核就随机自动分配车位 |
| | | //获取小区配置里配置的停车场id |
| | |
| | | reqJson.put("psId", "-1"); |
| | | } |
| | | } |
| | | |
| | | String result = ""; |
| | | if (existCar) { |
| | | result = "访客信息登记成功,车辆已经存在预约,请您在预约到期后,再次进行车辆预约,谢谢!"; |
| | |
| | | } |
| | | reqJson.put("stateRemark", result); |
| | | addVisit(reqJson); |
| | | //添加白名单 |
| | | if (reqJson.containsKey("state") && reqJson.getString("state").equals("1") |
| | | && !StringUtil.isEmpty(reqJson.getString("carNum"))) { //审核通过,且有车辆 |
| | | addBlackWhite(reqJson); |
| | | } |
| | | if (reqJson.containsKey("photo") && !StringUtils.isEmpty(reqJson.getString("photo"))) { |
| | | FileDto fileDto = new FileDto(); |
| | | fileDto.setFileId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_file_id)); |
| | | fileDto.setFileName(fileDto.getFileId()); |
| | | fileDto.setContext(reqJson.getString("photo")); |
| | | fileDto.setSuffix("jpeg"); |
| | | fileDto.setCommunityId(reqJson.getString("communityId")); |
| | | String fileName = fileInnerServiceSMOImpl.saveFile(fileDto); |
| | | reqJson.put("photoId", fileDto.getFileId()); |
| | | reqJson.put("fileSaveName", fileName); |
| | | if (reqJson.getString("photo").length() > 512) { //说明是图片 |
| | | FileDto fileDto = new FileDto(); |
| | | fileDto.setFileId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_file_id)); |
| | | fileDto.setFileName(fileDto.getFileId()); |
| | | fileDto.setContext(reqJson.getString("photo")); |
| | | fileDto.setSuffix("jpeg"); |
| | | fileDto.setCommunityId(reqJson.getString("communityId")); |
| | | String fileName = fileInnerServiceSMOImpl.saveFile(fileDto); |
| | | reqJson.put("photo", fileName); |
| | | |
| | | } |
| | | JSONObject businessUnit = new JSONObject(); |
| | | businessUnit.put("fileRelId", "-1"); |
| | | businessUnit.put("fileRelId", GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_fileRelId)); |
| | | businessUnit.put("relTypeCd", "11000"); |
| | | businessUnit.put("saveWay", "table"); |
| | | businessUnit.put("objId", reqJson.getString("vId")); |
| | | businessUnit.put("fileRealName", fileDto.getFileId()); |
| | | businessUnit.put("fileSaveName", fileName); |
| | | businessUnit.put("fileRealName", reqJson.getString("photo")); |
| | | businessUnit.put("fileSaveName", reqJson.getString("photo")); |
| | | FileRelPo fileRelPo = BeanConvertUtil.covertBean(businessUnit, FileRelPo.class); |
| | | fileRelInnerServiceSMOImpl.saveFileRel(fileRelPo); |
| | | } |
| | |
| | | ownerCarPo.setState(OwnerCarDto.STATE_NORMAL); //1001 正常状态,2002 车位释放欠费状态 3003 车位释放 |
| | | ownerCarPo.setCarTypeCd(OwnerCarDto.CAR_TYPE_TEMP); //1001 业主车辆 1002 成员车辆 1003 临时车 |
| | | ownerCarPo.setMemberId(reqJson.getString("ownerId")); |
| | | ownerCarPo.setLeaseType(OwnerCarDto.LEASE_TYPE_RESERVE); //H 月租车 S 出售车 I 内部车 NM 免费车 R 预约车 |
| | | ownerCarV1InnerServiceSMOImpl.saveOwnerCar(ownerCarPo); |
| | | //添加车辆属性 |
| | | OwnerCarAttrPo ownerCarAttrPo = new OwnerCarAttrPo(); |
| | |
| | | /** |
| | | * 添加小区信息 |
| | | * |
| | | * @param paramInJson 接口调用放传入入参 |
| | | * @param paramInJson 接口调用放传入入参 |
| | | * @return 订单服务能够接受的报文 |
| | | */ |
| | | public void addVisit(JSONObject paramInJson) { |
| | | |
| | | JSONObject businessVisit = new JSONObject(); |
| | | businessVisit.putAll(paramInJson); |
| | | |
| | | VisitPo visitPo = BeanConvertUtil.covertBean(businessVisit, VisitPo.class); |
| | | int flag =visitV1InnerServiceSMOImpl.saveVisit(visitPo); |
| | | if(flag <1){ |
| | | int flag = visitV1InnerServiceSMOImpl.saveVisit(visitPo); |
| | | if (flag < 1) { |
| | | throw new CmdException("保存访客失败"); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 添加白名单信息 |
| | | * |
| | | * @param paramInJson |
| | | */ |
| | | public void addBlackWhite(JSONObject paramInJson) { |
| | | CarBlackWhitePo carBlackWhitePo = new CarBlackWhitePo(); |
| | | carBlackWhitePo.setBwId(GenerateCodeFactory.getGeneratorId(CODE_PREFIX_ID)); |
| | | carBlackWhitePo.setbId("-1"); |
| | | carBlackWhitePo.setCommunityId(paramInJson.getString("communityId")); |
| | | carBlackWhitePo.setBlackWhite("2222"); //1111 黑名单 2222 白名单 |
| | | carBlackWhitePo.setCarNum(paramInJson.getString("carNum")); |
| | | carBlackWhitePo.setStartTime(paramInJson.getString("visitTime")); |
| | | carBlackWhitePo.setEndTime(paramInJson.getString("freeTime")); |
| | | SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | carBlackWhitePo.setCreateTime(simpleDateFormat.format(new Date())); |
| | | ParkingSpaceDto parkingSpaceDto = new ParkingSpaceDto(); |
| | | parkingSpaceDto.setPsId(paramInJson.getString("psId")); |
| | | List<ParkingSpaceDto> parkingSpaceDtos = parkingSpaceInnerServiceSMOImpl.queryParkingSpaces(parkingSpaceDto); //查询车位 |
| | | Assert.listOnlyOne(parkingSpaceDtos, "查询车位错误!"); |
| | | carBlackWhitePo.setPaId(parkingSpaceDtos.get(0).getPaId()); |
| | | carBlackWhiteV1InnerServiceSMOImpl.saveCarBlackWhite(carBlackWhitePo); |
| | | } |
| | | } |