|
|
@@ -4,20 +4,27 @@ import com.alibaba.fastjson.JSONObject;
|
|
|
import com.java110.api.listener.AbstractServiceApiListener;
|
|
|
import com.java110.core.annotation.Java110Listener;
|
|
|
import com.java110.core.context.DataFlowContext;
|
|
|
+import com.java110.core.smo.fee.IFeeConfigInnerServiceSMO;
|
|
|
import com.java110.core.smo.hardwareAdapation.ICarInoutInnerServiceSMO;
|
|
|
+import com.java110.dto.FeeConfigDto;
|
|
|
import com.java110.dto.hardwareAdapation.CarInoutDto;
|
|
|
import com.java110.event.service.api.ServiceDataFlowEvent;
|
|
|
+import com.java110.utils.constant.FeeTypeConstant;
|
|
|
import com.java110.utils.constant.ServiceCodeCarInoutConstant;
|
|
|
import com.java110.utils.util.Assert;
|
|
|
import com.java110.utils.util.BeanConvertUtil;
|
|
|
+import com.java110.utils.util.DateUtil;
|
|
|
import com.java110.vo.api.carInout.ApiCarInoutDataVo;
|
|
|
import com.java110.vo.api.carInout.ApiCarInoutVo;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.http.HttpMethod;
|
|
|
import org.springframework.http.HttpStatus;
|
|
|
import org.springframework.http.ResponseEntity;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
@@ -26,10 +33,15 @@ import java.util.List;
|
|
|
*/
|
|
|
@Java110Listener("listCarInoutsListener")
|
|
|
public class ListCarInoutsListener extends AbstractServiceApiListener {
|
|
|
+ private static Logger logger = LoggerFactory.getLogger(ListCarInoutsListener.class);
|
|
|
+
|
|
|
|
|
|
@Autowired
|
|
|
private ICarInoutInnerServiceSMO carInoutInnerServiceSMOImpl;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IFeeConfigInnerServiceSMO feeConfigInnerServiceSMOImpl;
|
|
|
+
|
|
|
@Override
|
|
|
public String getServiceCode() {
|
|
|
return ServiceCodeCarInoutConstant.LIST_CARINOUTS;
|
|
|
@@ -78,6 +90,8 @@ public class ListCarInoutsListener extends AbstractServiceApiListener {
|
|
|
|
|
|
if (count > 0) {
|
|
|
carInouts = BeanConvertUtil.covertBeanList(carInoutInnerServiceSMOImpl.queryCarInouts(carInoutDto), ApiCarInoutDataVo.class);
|
|
|
+
|
|
|
+ refreshCarInout(carInouts,reqJson.getString("communityId"));
|
|
|
} else {
|
|
|
carInouts = new ArrayList<>();
|
|
|
}
|
|
|
@@ -93,4 +107,56 @@ public class ListCarInoutsListener extends AbstractServiceApiListener {
|
|
|
context.setResponseEntity(responseEntity);
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 刷新返回数据 加入 停车时间和 应收费用
|
|
|
+ * @param carInouts
|
|
|
+ */
|
|
|
+ private void refreshCarInout(List<ApiCarInoutDataVo> carInouts,String communityId) {
|
|
|
+
|
|
|
+ Date nowTime = new Date();
|
|
|
+ Date inTime = null;
|
|
|
+
|
|
|
+ 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);
|
|
|
+ for(ApiCarInoutDataVo apiCarInoutDataVo : carInouts){
|
|
|
+ if("100500".equals(apiCarInoutDataVo.getState())){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ inTime = DateUtil.getDateFromString(apiCarInoutDataVo.getInTime(), DateUtil.DATE_FORMATE_STRING_A);
|
|
|
+ }catch (Exception e){
|
|
|
+ logger.error("格式化入场时间出错",e);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ 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());
|
|
|
+ }
|
|
|
+ apiCarInoutDataVo.setMoney(money);
|
|
|
+ apiCarInoutDataVo.setInHours(new Double(hour).intValue());
|
|
|
+ apiCarInoutDataVo.setInMin(new Double(min).intValue());
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
}
|