瀏覽代碼

优化boot版处理

java110 3 年之前
父節點
當前提交
8f8945eca2

+ 10 - 0
java110-bean/src/main/java/com/java110/dto/machine/CarBlackWhiteDto.java

@@ -29,6 +29,8 @@ public class CarBlackWhiteDto extends PageDto implements Serializable {
     private String[] paIds;
     private String paNum;
 
+    private String validity;
+
 
     private Date createTime;
 
@@ -131,4 +133,12 @@ public class CarBlackWhiteDto extends PageDto implements Serializable {
     public void setPaIds(String[] paIds) {
         this.paIds = paIds;
     }
+
+    public String getValidity() {
+        return validity;
+    }
+
+    public void setValidity(String validity) {
+        this.validity = validity;
+    }
 }

+ 2 - 0
java110-bean/src/main/java/com/java110/dto/machine/CarInoutDto.java

@@ -23,6 +23,8 @@ public class CarInoutDto extends CarInoutPaymentDto implements Serializable {
     public static final String STATE_REPAY = "100600";
 
     public static final String STATE_IN_FAIL = "100301";
+    public static final String CAR_TYPE_MONTH = "1001";
+    public static final String CAR_TYPE_TEMP = "1003";
 
 
     private String inTime;

+ 15 - 1
java110-core/src/main/java/com/java110/core/factory/CallApiServiceFactory.java

@@ -2,6 +2,7 @@ package com.java110.core.factory;
 
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import com.java110.core.context.Environment;
 import com.java110.core.context.IPageData;
 import com.java110.core.context.PageData;
 import com.java110.core.log.LoggerFactory;
@@ -25,12 +26,14 @@ import java.util.Map;
 public class CallApiServiceFactory {
 
     private static final String URL_API = "http://api-service/api/";
+    private static final String URL_BOOT_API = "http://127.0.0.1:8008/api/";
     //日志
     private static Logger logger = LoggerFactory.getLogger(CallApiServiceFactory.class);
 
     @Autowired
     private RestTemplate restTemplate;
 
+
     /**
      * 查询
      *
@@ -142,6 +145,10 @@ public class CallApiServiceFactory {
 
         String url = URL_API + serviceCode;
         RestTemplate restTemplate = ApplicationContextFactory.getBean("restTemplate", RestTemplate.class);
+        if (Environment.isStartBootWay()) {
+            url = URL_BOOT_API + serviceCode;
+            restTemplate = ApplicationContextFactory.getBean("outRestTemplate", RestTemplate.class);
+        }
 
 
         ResponseEntity<String> responseEntity = callCenterService(restTemplate, pd, JSONObject.toJSONString(param), url, HttpMethod.POST);
@@ -183,10 +190,16 @@ public class CallApiServiceFactory {
     public static <T> List<T> getForApis(IPageData pd, T param, String serviceCode, Class<T> t) {
 
         String url = URL_API + serviceCode;
+        RestTemplate restTemplate = ApplicationContextFactory.getBean("restTemplate", RestTemplate.class);
+
+        if (Environment.isStartBootWay()) {
+            url = URL_BOOT_API + serviceCode;
+            restTemplate = ApplicationContextFactory.getBean("outRestTemplate", RestTemplate.class);
+        }
+
         if (param != null) {
             url += mapToUrlParam(BeanConvertUtil.beanCovertMap(param));
         }
-        RestTemplate restTemplate = ApplicationContextFactory.getBean("restTemplate", RestTemplate.class);
 
         ResponseEntity<String> responseEntity = callCenterService(restTemplate, pd, "", url, HttpMethod.GET);
 
@@ -239,6 +252,7 @@ public class CallApiServiceFactory {
 
         HttpEntity<String> httpEntity = new HttpEntity<String>(param, header);
         //logger.debug("请求中心服务信息,{}", httpEntity);
+
         try {
             responseEntity = restTemplate.exchange(url, httpMethod, httpEntity, String.class);
         } catch (HttpStatusCodeException e) { //这里spring 框架 在4XX 或 5XX 时抛出 HttpServerErrorException 异常,需要重新封装一下

+ 102 - 95
java110-db/src/main/resources/mapper/user/CarBlackWhiteV1ServiceDaoImplMapper.xml

@@ -5,120 +5,127 @@
 <mapper namespace="carBlackWhiteV1ServiceDaoImpl">
 
 
-
-
-
     <!-- 保存车辆黑白名单信息 add by wuxw 2018-07-03 -->
     <insert id="saveCarBlackWhiteInfo" parameterType="Map">
         insert into car_black_white(
-black_white,pa_id,car_num,start_time,end_time,community_id,bw_id
-) values (
-#{blackWhite},#{paId},#{carNum},#{startTime},#{endTime},#{communityId},#{bwId}
-)
+        black_white,pa_id,car_num,start_time,end_time,community_id,bw_id
+        ) values (
+        #{blackWhite},#{paId},#{carNum},#{startTime},#{endTime},#{communityId},#{bwId}
+        )
     </insert>
 
 
-
     <!-- 查询车辆黑白名单信息 add by wuxw 2018-07-03 -->
     <select id="getCarBlackWhiteInfo" parameterType="Map" resultType="Map">
-        select  t.black_white,t.black_white blackWhite,t.pa_id,t.pa_id paId,t.car_num,t.car_num carNum,t.start_time,t.start_time startTime,t.status_cd,t.status_cd statusCd,t.end_time,t.end_time endTime,t.community_id,t.community_id communityId,t.bw_id,t.bw_id bwId 
-from car_black_white t 
-where 1 =1 
-<if test="blackWhite !=null and blackWhite != ''">
-   and t.black_white= #{blackWhite}
-</if> 
-<if test="paId !=null and paId != ''">
-   and t.pa_id= #{paId}
-</if> 
-<if test="carNum !=null and carNum != ''">
-   and t.car_num= #{carNum}
-</if> 
-<if test="startTime !=null and startTime != ''">
-   and t.start_time= #{startTime}
-</if> 
-<if test="statusCd !=null and statusCd != ''">
-   and t.status_cd= #{statusCd}
-</if> 
-<if test="endTime !=null and endTime != ''">
-   and t.end_time= #{endTime}
-</if> 
-<if test="communityId !=null and communityId != ''">
-   and t.community_id= #{communityId}
-</if> 
-<if test="bwId !=null and bwId != ''">
-   and t.bw_id= #{bwId}
-</if> 
-order by t.create_time desc
-<if test="page != -1 and page != null ">
-   limit #{page}, #{row}
-</if> 
+        select t.black_white,t.black_white blackWhite,t.pa_id,t.pa_id paId,t.car_num,t.car_num
+        carNum,t.start_time,t.start_time startTime,t.status_cd,t.status_cd statusCd,t.end_time,t.end_time
+        endTime,t.community_id,t.community_id communityId,t.bw_id,t.bw_id bwId
+        from car_black_white t
+        where 1 =1
+        <if test="blackWhite !=null and blackWhite != ''">
+            and t.black_white= #{blackWhite}
+        </if>
+        <if test="paId !=null and paId != ''">
+            and t.pa_id= #{paId}
+        </if>
+        <if test="carNum !=null and carNum != ''">
+            and t.car_num= #{carNum}
+        </if>
+        <if test="startTime !=null and startTime != ''">
+            and t.start_time= #{startTime}
+        </if>
+        <if test="statusCd !=null and statusCd != ''">
+            and t.status_cd= #{statusCd}
+        </if>
+        <if test="endTime !=null and endTime != ''">
+            and t.end_time= #{endTime}
+        </if>
+        <if test="communityId !=null and communityId != ''">
+            and t.community_id= #{communityId}
+        </if>
+        <if test="validity !=null and validity != ''">
+            and t.end_time &gt; now()
+            and t.start_time &lt; now()
+        </if>
+        <if test="bwId !=null and bwId != ''">
+            and t.bw_id= #{bwId}
+        </if>
+        order by t.create_time desc
+        <if test="page != -1 and page != null ">
+            limit #{page}, #{row}
+        </if>
 
     </select>
 
 
-
-
     <!-- 修改车辆黑白名单信息 add by wuxw 2018-07-03 -->
     <update id="updateCarBlackWhiteInfo" parameterType="Map">
-        update  car_black_white t set t.status_cd = #{statusCd}
-<if test="newBId != null and newBId != ''">
-,t.b_id = #{newBId}
-</if> 
-<if test="blackWhite !=null and blackWhite != ''">
-, t.black_white= #{blackWhite}
-</if> 
-<if test="paId !=null and paId != ''">
-, t.pa_id= #{paId}
-</if> 
-<if test="carNum !=null and carNum != ''">
-, t.car_num= #{carNum}
-</if> 
-<if test="startTime !=null and startTime != ''">
-, t.start_time= #{startTime}
-</if> 
-<if test="endTime !=null and endTime != ''">
-, t.end_time= #{endTime}
-</if> 
-<if test="communityId !=null and communityId != ''">
-, t.community_id= #{communityId}
-</if> 
- where 1=1 <if test="bwId !=null and bwId != ''">
-and t.bw_id= #{bwId}
-</if> 
+        update car_black_white t set t.status_cd = #{statusCd}
+        <if test="newBId != null and newBId != ''">
+            ,t.b_id = #{newBId}
+        </if>
+        <if test="blackWhite !=null and blackWhite != ''">
+            , t.black_white= #{blackWhite}
+        </if>
+        <if test="paId !=null and paId != ''">
+            , t.pa_id= #{paId}
+        </if>
+        <if test="carNum !=null and carNum != ''">
+            , t.car_num= #{carNum}
+        </if>
+        <if test="startTime !=null and startTime != ''">
+            , t.start_time= #{startTime}
+        </if>
+        <if test="endTime !=null and endTime != ''">
+            , t.end_time= #{endTime}
+        </if>
+        <if test="communityId !=null and communityId != ''">
+            , t.community_id= #{communityId}
+        </if>
+        where 1=1
+        <if test="bwId !=null and bwId != ''">
+            and t.bw_id= #{bwId}
+        </if>
 
     </update>
 
     <!-- 查询车辆黑白名单数量 add by wuxw 2018-07-03 -->
-     <select id="queryCarBlackWhitesCount" parameterType="Map" resultType="Map">
-        select  count(1) count 
-from car_black_white t 
-where 1 =1 
-<if test="blackWhite !=null and blackWhite != ''">
-   and t.black_white= #{blackWhite}
-</if> 
-<if test="paId !=null and paId != ''">
-   and t.pa_id= #{paId}
-</if> 
-<if test="carNum !=null and carNum != ''">
-   and t.car_num= #{carNum}
-</if> 
-<if test="startTime !=null and startTime != ''">
-   and t.start_time= #{startTime}
-</if> 
-<if test="statusCd !=null and statusCd != ''">
-   and t.status_cd= #{statusCd}
-</if> 
-<if test="endTime !=null and endTime != ''">
-   and t.end_time= #{endTime}
-</if> 
-<if test="communityId !=null and communityId != ''">
-   and t.community_id= #{communityId}
-</if> 
-<if test="bwId !=null and bwId != ''">
-   and t.bw_id= #{bwId}
-</if> 
+    <select id="queryCarBlackWhitesCount" parameterType="Map" resultType="Map">
+        select count(1) count
+        from car_black_white t
+        where 1 =1
+        <if test="blackWhite !=null and blackWhite != ''">
+            and t.black_white= #{blackWhite}
+        </if>
+        <if test="paId !=null and paId != ''">
+            and t.pa_id= #{paId}
+        </if>
+        <if test="carNum !=null and carNum != ''">
+            and t.car_num= #{carNum}
+        </if>
+        <if test="startTime !=null and startTime != ''">
+            and t.start_time= #{startTime}
+        </if>
+        <if test="statusCd !=null and statusCd != ''">
+            and t.status_cd= #{statusCd}
+        </if>
+        <if test="endTime !=null and endTime != ''">
+            and t.end_time= #{endTime}
+        </if>
+        <if test="validity !=null and validity != ''">
+            and t.end_time &gt; now()
+            and t.start_time &lt; now()
+        </if>
+
+
+        <if test="communityId !=null and communityId != ''">
+            and t.community_id= #{communityId}
+        </if>
+        <if test="bwId !=null and bwId != ''">
+            and t.bw_id= #{bwId}
+        </if>
 
 
-     </select>
+    </select>
 
 </mapper>

+ 14 - 0
service-common/src/main/java/com/java110/common/cmd/machine/CustomCarInOutCmd.java

@@ -17,18 +17,21 @@ package com.java110.common.cmd.machine;
 
 import com.alibaba.fastjson.JSONObject;
 import com.java110.common.bmo.machine.IMachineOpenDoorBMO;
+import com.java110.common.dao.ICarBlackWhiteServiceDao;
 import com.java110.common.dao.ICarInoutV1ServiceDao;
 import com.java110.core.annotation.Java110Cmd;
 import com.java110.core.context.ICmdDataFlowContext;
 import com.java110.core.event.cmd.Cmd;
 import com.java110.core.event.cmd.CmdEvent;
 import com.java110.core.factory.GenerateCodeFactory;
+import com.java110.dto.machine.CarBlackWhiteDto;
 import com.java110.dto.machine.CarInoutDto;
 import com.java110.dto.parkingBoxArea.ParkingBoxAreaDto;
 import com.java110.dto.tempCarFeeConfig.TempCarPayOrderDto;
 import com.java110.intf.common.ICarInoutV1InnerServiceSMO;
 import com.java110.intf.community.IParkingBoxAreaV1InnerServiceSMO;
 import com.java110.intf.job.IDataBusInnerServiceSMO;
+import com.java110.intf.user.ICarBlackWhiteV1InnerServiceSMO;
 import com.java110.utils.exception.CmdException;
 import com.java110.utils.util.Assert;
 import com.java110.utils.util.DateUtil;
@@ -71,6 +74,9 @@ public class CustomCarInOutCmd extends Cmd {
     @Autowired
     private ICarInoutV1InnerServiceSMO carInoutV1InnerServiceSMOImpl;
 
+    @Autowired
+    private ICarBlackWhiteV1InnerServiceSMO carBlackWhiteV1InnerServiceSMOImpl;
+
     @Override
     public void validate(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) {
         Assert.hasKeyAndValue(reqJson, "communityId", "请求报文中未包含小区信息");
@@ -86,6 +92,7 @@ public class CustomCarInOutCmd extends Cmd {
         });
         int count = carInoutV1InnerServiceSMOImpl.queryCarInoutsCount(carInoutDto);
 
+        //出场
         if(!"1101".equals(reqJson.getString("type"))) {
             Assert.hasKeyAndValue(reqJson,"payType","未包含支付方式");
             Assert.hasKeyAndValue(reqJson,"amount","未包含支付金额");
@@ -96,6 +103,13 @@ public class CustomCarInOutCmd extends Cmd {
             if(count > 0){
                 throw new CmdException("车辆已经在场,请先出场");
             }
+            //进场时 判断是否为黑名单
+            CarBlackWhiteDto carBlackWhiteDto = new CarBlackWhiteDto();
+            carBlackWhiteDto.setCarNum(reqJson.getString("carNum"));
+            count =  carBlackWhiteV1InnerServiceSMOImpl.queryCarBlackWhitesCount(carBlackWhiteDto);
+            if(count > 0){
+                throw new CmdException("黑名单车辆禁止入场");
+            }
         }
 
 

+ 5 - 0
service-community/src/main/java/com/java110/community/cmd/room/SaveRoomCmd.java

@@ -2,6 +2,7 @@ package com.java110.community.cmd.room;
 
 import com.alibaba.fastjson.JSONObject;
 import com.java110.core.annotation.Java110Cmd;
+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;
@@ -11,6 +12,7 @@ import com.java110.dto.UnitDto;
 import com.java110.intf.community.IRoomV1InnerServiceSMO;
 import com.java110.intf.community.IUnitInnerServiceSMO;
 import com.java110.po.room.RoomPo;
+import com.java110.utils.cache.MappingCache;
 import com.java110.utils.constant.CommonConstant;
 import com.java110.utils.exception.CmdException;
 import com.java110.utils.util.Assert;
@@ -81,12 +83,15 @@ public class SaveRoomCmd extends Cmd {
     }
 
     @Override
+    @Java110Transactional
     public void doCmd(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException {
         if ("0".equals(reqJson.getString("unitNum"))) { // 处理为商铺
             reqJson.put("roomType", RoomDto.ROOM_TYPE_SHOPS);
         } else {
             reqJson.put("roomType", RoomDto.ROOM_TYPE_ROOM);
         }
+
+
         reqJson.put("roomId", GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_roomId));
         reqJson.put("userId", context.getReqHeaders().get(CommonConstant.HTTP_USER_ID));
         RoomPo roomPo = BeanConvertUtil.covertBean(reqJson, RoomPo.class);

+ 5 - 1
service-fee/src/main/java/com/java110/fee/smo/impl/TempCarFeeConfigInnerServiceSMOImpl.java

@@ -134,7 +134,11 @@ public class TempCarFeeConfigInnerServiceSMOImpl extends BaseServiceSMO implemen
                 TempCarFeeResult result = computeTempCarFee.computeTempCarFee(carInoutDto, tempCarFeeConfigDtos.get(0), tempCarFeeConfigAttrDtos);
                 carInoutDto.setMin(result.getMin());
                 carInoutDto.setHours(result.getHours());
-                carInoutDto.setPayCharge(result.getPayCharge() + "");
+                if(CarInoutDto.CAR_TYPE_MONTH.equals(carInoutDto.getCarType())){
+                    carInoutDto.setPayCharge( "0.00");
+                }else {
+                    carInoutDto.setPayCharge(result.getPayCharge() + "");
+                }
             } catch (Exception e) {
                 logger.error("临时车算费失败", e);
             }