| | |
| | | Assert.hasKeyAndValue(reqJson, "communityId", "请求报文中未包含communityId"); |
| | | |
| | | if (reqJson.containsKey("exit_time")) { |
| | | reqJson.put("outTime", reqJson.getString("exit_time")); |
| | | reqJson.put("state" , "100500"); |
| | | }else { |
| | | reqJson.put("state" , "100300"); |
| | |
| | | @Override |
| | | @Java110Transactional |
| | | public void doCmd(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) throws CmdException { |
| | | if(reqJson.containsKey("exit_time")){//出口 |
| | | if(reqJson.get("paid_status").equals("true")){//已收取现金 |
| | | CarInoutPo carInoutPo = BeanConvertUtil.covertBean(reqJson, CarInoutPo.class); |
| | | carInoutPo.setInoutId(GenerateCodeFactory.getGeneratorId(CODE_PREFIX_ID)); |
| | | int flag = carInoutV1InnerServiceSMOImpl.saveCarInout(carInoutPo); |
| | | |
| | | CarInoutPo carInoutPo = BeanConvertUtil.covertBean(reqJson, CarInoutPo.class); |
| | | carInoutPo.setInoutId(GenerateCodeFactory.getGeneratorId(CODE_PREFIX_ID)); |
| | | int flag = carInoutV1InnerServiceSMOImpl.saveCarInout(carInoutPo); |
| | | if (flag < 1) { |
| | | throw new CmdException("保存数据失败"); |
| | | } |
| | | JSONObject jsonObject = new JSONObject(); |
| | | jsonObject.put("allow_exit", "true"); |
| | | jsonObject.put("message","允许通行"); |
| | | jsonObject.put("payment_required","true"); |
| | | jsonObject.put("amount_due",reqJson.get("payment_amount")); |
| | | ResponseEntity<String> responseEntity = ResponseEntity |
| | | .ok() |
| | | .header("Content-Type", "application/json") |
| | | .body(jsonObject.toString()); // 关键:用toString()返回原始JSON字符串 |
| | | |
| | | if (flag < 1) { |
| | | throw new CmdException("保存数据失败"); |
| | | cmdDataFlowContext.setResponseEntity(responseEntity); |
| | | } |
| | | else if(reqJson.get("vehicle_type").equals("monthly")){ |
| | | if(reqJson.get("paid_status").equals("false")){ |
| | | JSONObject jsonObject = new JSONObject(); |
| | | jsonObject.put("allow_exit", "false"); |
| | | jsonObject.put("message","租车费用未结清,请补缴后通行"); |
| | | jsonObject.put("payment_required","false"); |
| | | jsonObject.put("amount_due",reqJson.get("payment_amount")); |
| | | ResponseEntity<String> responseEntity = ResponseEntity |
| | | .ok() |
| | | .header("Content-Type", "application/json") |
| | | .body(jsonObject.toString()); // 关键:用toString()返回原始JSON字符串 |
| | | |
| | | cmdDataFlowContext.setResponseEntity(responseEntity); |
| | | }else{ |
| | | CarInoutPo carInoutPo = BeanConvertUtil.covertBean(reqJson, CarInoutPo.class); |
| | | carInoutPo.setInoutId(GenerateCodeFactory.getGeneratorId(CODE_PREFIX_ID)); |
| | | int flag = carInoutV1InnerServiceSMOImpl.saveCarInout(carInoutPo); |
| | | |
| | | if (flag < 1) { |
| | | throw new CmdException("保存数据失败"); |
| | | } |
| | | JSONObject jsonObject = new JSONObject(); |
| | | jsonObject.put("allow_exit", "true"); |
| | | jsonObject.put("message","允许通行"); |
| | | jsonObject.put("payment_required","true"); |
| | | jsonObject.put("amount_due","0"); |
| | | ResponseEntity<String> responseEntity = ResponseEntity |
| | | .ok() |
| | | .header("Content-Type", "application/json") |
| | | .body(jsonObject.toString()); // 关键:用toString()返回原始JSON字符串 |
| | | |
| | | cmdDataFlowContext.setResponseEntity(responseEntity); |
| | | } |
| | | } |
| | | else if(1 == 1){//如果不能直接支付 |
| | | JSONObject jsonObject = new JSONObject(); |
| | | jsonObject.put("allow_exit", "false"); |
| | | jsonObject.put("message","请支付金额"+reqJson.get("payment_amount")); |
| | | jsonObject.put("payment_required","false"); |
| | | jsonObject.put("amount_due",reqJson.get("payment_amount")); |
| | | ResponseEntity<String> responseEntity = ResponseEntity |
| | | .ok() |
| | | .header("Content-Type", "application/json") |
| | | .body(jsonObject.toString()); // 关键:用toString()返回原始JSON字符串 |
| | | |
| | | cmdDataFlowContext.setResponseEntity(responseEntity); |
| | | }else{//能直接支付 |
| | | CarInoutPo carInoutPo = BeanConvertUtil.covertBean(reqJson, CarInoutPo.class); |
| | | carInoutPo.setInoutId(GenerateCodeFactory.getGeneratorId(CODE_PREFIX_ID)); |
| | | int flag = carInoutV1InnerServiceSMOImpl.saveCarInout(carInoutPo); |
| | | |
| | | if (flag < 1) { |
| | | throw new CmdException("保存数据失败"); |
| | | } |
| | | JSONObject jsonObject = new JSONObject(); |
| | | jsonObject.put("allow_exit", "true"); |
| | | jsonObject.put("message","允许通行"); |
| | | jsonObject.put("payment_required","true"); |
| | | jsonObject.put("amount_due",reqJson.get("payment_amount")); |
| | | ResponseEntity<String> responseEntity = ResponseEntity |
| | | .ok() |
| | | .header("Content-Type", "application/json") |
| | | .body(jsonObject.toString()); // 关键:用toString()返回原始JSON字符串 |
| | | |
| | | cmdDataFlowContext.setResponseEntity(responseEntity); |
| | | } |
| | | }else{//进口 |
| | | CarInoutPo carInoutPo = BeanConvertUtil.covertBean(reqJson, CarInoutPo.class); |
| | | carInoutPo.setInoutId(GenerateCodeFactory.getGeneratorId(CODE_PREFIX_ID)); |
| | | int flag = carInoutV1InnerServiceSMOImpl.saveCarInout(carInoutPo); |
| | | |
| | | if (flag < 1) { |
| | | throw new CmdException("保存数据失败"); |
| | | } |
| | | JSONObject jsonObject = new JSONObject(); |
| | | jsonObject.put("allow_entry","true"); |
| | | jsonObject.put("message","允许通行"); |
| | | jsonObject.put("expire_date","");// 如果是包月车,返回有效期 |
| | | ResponseEntity<String> responseEntity = ResponseEntity |
| | | .ok() |
| | | .header("Content-Type", "application/json") |
| | | .body(jsonObject.toString()); // 关键:用toString()返回原始JSON字符串 |
| | | |
| | | cmdDataFlowContext.setResponseEntity(responseEntity); |
| | | } |
| | | JSONObject jsonObject = new JSONObject(); |
| | | jsonObject.put("allow_entry","true"); |
| | | jsonObject.put("message","允许通行"); |
| | | jsonObject.put("expire_date","");// 如果是包月车,返回有效期 |
| | | ResponseEntity<String> responseEntity = ResponseEntity |
| | | .ok() |
| | | .header("Content-Type", "application/json") |
| | | .body(jsonObject.toString()); // 关键:用toString()返回原始JSON字符串 |
| | | |
| | | cmdDataFlowContext.setResponseEntity(responseEntity); |
| | | } |
| | | } |