Kaynağa Gözat

优化代码

java110 3 yıl önce
ebeveyn
işleme
03afe0f73a

+ 19 - 0
java110-bean/src/main/java/com/java110/dto/parkingCoupon/ParkingCouponDto.java

@@ -20,9 +20,12 @@ public class ParkingCouponDto extends PageDto implements Serializable {
     public static final String TYPE_CD_DISCOUNT = "3003";
     public static final String TYPE_CD_FREE = "4004";
 
+
     private String typeCd;
+    private String typeCdName;
     private String name;
     private String paId;
+    private String paName;
     private String couponId;
     private String communityId;
     private String value;
@@ -106,4 +109,20 @@ public class ParkingCouponDto extends PageDto implements Serializable {
     public void setStatusCd(String statusCd) {
         this.statusCd = statusCd;
     }
+
+    public String getTypeCdName() {
+        return typeCdName;
+    }
+
+    public void setTypeCdName(String typeCdName) {
+        this.typeCdName = typeCdName;
+    }
+
+    public String getPaName() {
+        return paName;
+    }
+
+    public void setPaName(String paName) {
+        this.paName = paName;
+    }
 }

+ 50 - 25
java110-bean/src/main/java/com/java110/po/parkingCoupon/ParkingCouponPo.java

@@ -16,7 +16,7 @@
 package com.java110.po.parkingCoupon;
 
 import java.io.Serializable;
-import java.util.Date;
+
 /**
  * 类表述: Po 数据模型实体对象 基本保持与数据库模型一直 用于 增加修改删除 等时的数据载体
  * add by 吴学文 at 2022-10-10 13:27:02 mail: 928255095@qq.com
@@ -28,62 +28,87 @@ import java.util.Date;
 public class ParkingCouponPo implements Serializable {
 
     private String typeCd;
-private String name;
-private String paId;
-private String statusCd = "0";
-private String couponId;
-private String communityId;
-private String value;
-private String valuePrice;
-public String getTypeCd() {
+    private String name;
+    private String paId;
+
+
+
+    private String paName;
+    private String statusCd = "0";
+    private String couponId;
+    private String communityId;
+    private String value;
+    private String valuePrice;
+
+    public String getTypeCd() {
         return typeCd;
     }
-public void setTypeCd(String typeCd) {
+
+    public void setTypeCd(String typeCd) {
         this.typeCd = typeCd;
     }
-public String getName() {
+
+    public String getName() {
         return name;
     }
-public void setName(String name) {
+
+    public void setName(String name) {
         this.name = name;
     }
-public String getPaId() {
+
+    public String getPaId() {
         return paId;
     }
-public void setPaId(String paId) {
+
+    public void setPaId(String paId) {
         this.paId = paId;
     }
-public String getStatusCd() {
+
+    public String getStatusCd() {
         return statusCd;
     }
-public void setStatusCd(String statusCd) {
+
+    public void setStatusCd(String statusCd) {
         this.statusCd = statusCd;
     }
-public String getCouponId() {
+
+    public String getCouponId() {
         return couponId;
     }
-public void setCouponId(String couponId) {
+
+    public void setCouponId(String couponId) {
         this.couponId = couponId;
     }
-public String getCommunityId() {
+
+    public String getCommunityId() {
         return communityId;
     }
-public void setCommunityId(String communityId) {
+
+    public void setCommunityId(String communityId) {
         this.communityId = communityId;
     }
-public String getValue() {
+
+    public String getValue() {
         return value;
     }
-public void setValue(String value) {
+
+    public void setValue(String value) {
         this.value = value;
     }
-public String getValuePrice() {
+
+    public String getValuePrice() {
         return valuePrice;
     }
-public void setValuePrice(String valuePrice) {
+
+    public void setValuePrice(String valuePrice) {
         this.valuePrice = valuePrice;
     }
 
+    public String getPaName() {
+        return paName;
+    }
 
-
+    public void setPaName(String paName) {
+        this.paName = paName;
+    }
 }

+ 96 - 95
java110-db/src/main/resources/mapper/acct/ParkingCouponV1ServiceDaoImplMapper.xml

@@ -5,120 +5,121 @@
 <mapper namespace="parkingCouponV1ServiceDaoImpl">
 
 
-
-
-
     <!-- 保存停车卷信息 add by wuxw 2018-07-03 -->
     <insert id="saveParkingCouponInfo" parameterType="Map">
         insert into parking_coupon(
-type_cd,name,pa_id,coupon_id,community_id,value,value_price
-) values (
-#{typeCd},#{name},#{paId},#{couponId},#{communityId},#{value},#{valuePrice}
-)
+        type_cd,name,pa_id,pa_name,coupon_id,community_id,value,value_price
+        ) values (
+        #{typeCd},#{name},#{paId},#{paName},#{couponId},#{communityId},#{value},#{valuePrice}
+        )
     </insert>
 
 
-
     <!-- 查询停车卷信息 add by wuxw 2018-07-03 -->
     <select id="getParkingCouponInfo" parameterType="Map" resultType="Map">
-        select  t.type_cd,t.type_cd typeCd,t.name,t.pa_id,t.pa_id paId,t.status_cd,t.status_cd statusCd,t.coupon_id,t.coupon_id couponId,t.community_id,t.community_id communityId,t.value,t.value_price,t.value_price valuePrice 
-from parking_coupon t 
-where 1 =1 
-<if test="typeCd !=null and typeCd != ''">
-   and t.type_cd= #{typeCd}
-</if> 
-<if test="name !=null and name != ''">
-   and t.name= #{name}
-</if> 
-<if test="paId !=null and paId != ''">
-   and t.pa_id= #{paId}
-</if> 
-<if test="statusCd !=null and statusCd != ''">
-   and t.status_cd= #{statusCd}
-</if> 
-<if test="couponId !=null and couponId != ''">
-   and t.coupon_id= #{couponId}
-</if> 
-<if test="communityId !=null and communityId != ''">
-   and t.community_id= #{communityId}
-</if> 
-<if test="value !=null and value != ''">
-   and t.value= #{value}
-</if> 
-<if test="valuePrice !=null and valuePrice != ''">
-   and t.value_price= #{valuePrice}
-</if> 
-order by t.create_time desc
-<if test="page != -1 and page != null ">
-   limit #{page}, #{row}
-</if> 
+        select t.type_cd,t.type_cd typeCd,t.name,t.pa_id,t.pa_id paId,t.pa_name paName,t.status_cd,t.status_cd
+        statusCd,t.coupon_id,t.coupon_id couponId,t.community_id,t.community_id
+        communityId,t.value,t.value_price,t.value_price valuePrice,td.name typeCdName
+        from parking_coupon t
+        left join t_dict td on t.type_cd = td.status_cd and td.table_name = 'parking_coupon' and td.table_columns = 'type_cd'
+        where 1 =1
+        <if test="typeCd !=null and typeCd != ''">
+            and t.type_cd= #{typeCd}
+        </if>
+        <if test="name !=null and name != ''">
+            and t.name= #{name}
+        </if>
+        <if test="paId !=null and paId != ''">
+            and t.pa_id= #{paId}
+        </if>
+        <if test="statusCd !=null and statusCd != ''">
+            and t.status_cd= #{statusCd}
+        </if>
+        <if test="couponId !=null and couponId != ''">
+            and t.coupon_id= #{couponId}
+        </if>
+        <if test="communityId !=null and communityId != ''">
+            and t.community_id= #{communityId}
+        </if>
+        <if test="value !=null and value != ''">
+            and t.value= #{value}
+        </if>
+        <if test="valuePrice !=null and valuePrice != ''">
+            and t.value_price= #{valuePrice}
+        </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="updateParkingCouponInfo" parameterType="Map">
-        update  parking_coupon t set t.status_cd = #{statusCd}
-<if test="newBId != null and newBId != ''">
-,t.b_id = #{newBId}
-</if> 
-<if test="typeCd !=null and typeCd != ''">
-, t.type_cd= #{typeCd}
-</if> 
-<if test="name !=null and name != ''">
-, t.name= #{name}
-</if> 
-<if test="paId !=null and paId != ''">
-, t.pa_id= #{paId}
-</if> 
-<if test="communityId !=null and communityId != ''">
-, t.community_id= #{communityId}
-</if> 
-<if test="value !=null and value != ''">
-, t.value= #{value}
-</if> 
-<if test="valuePrice !=null and valuePrice != ''">
-, t.value_price= #{valuePrice}
-</if> 
- where 1=1 <if test="couponId !=null and couponId != ''">
-and t.coupon_id= #{couponId}
-</if> 
+        update parking_coupon t set t.status_cd = #{statusCd}
+        <if test="newBId != null and newBId != ''">
+            ,t.b_id = #{newBId}
+        </if>
+        <if test="typeCd !=null and typeCd != ''">
+            , t.type_cd= #{typeCd}
+        </if>
+        <if test="name !=null and name != ''">
+            , t.name= #{name}
+        </if>
+        <if test="paId !=null and paId != ''">
+            , t.pa_id= #{paId}
+        </if>
+        <if test="paName !=null and paName != ''">
+            , t.pa_name= #{paName}
+        </if>
+        <if test="communityId !=null and communityId != ''">
+            , t.community_id= #{communityId}
+        </if>
+        <if test="value !=null and value != ''">
+            , t.value= #{value}
+        </if>
+        <if test="valuePrice !=null and valuePrice != ''">
+            , t.value_price= #{valuePrice}
+        </if>
+        where 1=1
+        <if test="couponId !=null and couponId != ''">
+            and t.coupon_id= #{couponId}
+        </if>
 
     </update>
 
     <!-- 查询停车卷数量 add by wuxw 2018-07-03 -->
-     <select id="queryParkingCouponsCount" parameterType="Map" resultType="Map">
-        select  count(1) count 
-from parking_coupon t 
-where 1 =1 
-<if test="typeCd !=null and typeCd != ''">
-   and t.type_cd= #{typeCd}
-</if> 
-<if test="name !=null and name != ''">
-   and t.name= #{name}
-</if> 
-<if test="paId !=null and paId != ''">
-   and t.pa_id= #{paId}
-</if> 
-<if test="statusCd !=null and statusCd != ''">
-   and t.status_cd= #{statusCd}
-</if> 
-<if test="couponId !=null and couponId != ''">
-   and t.coupon_id= #{couponId}
-</if> 
-<if test="communityId !=null and communityId != ''">
-   and t.community_id= #{communityId}
-</if> 
-<if test="value !=null and value != ''">
-   and t.value= #{value}
-</if> 
-<if test="valuePrice !=null and valuePrice != ''">
-   and t.value_price= #{valuePrice}
-</if> 
+    <select id="queryParkingCouponsCount" parameterType="Map" resultType="Map">
+        select count(1) count
+        from parking_coupon t
+        where 1 =1
+        <if test="typeCd !=null and typeCd != ''">
+            and t.type_cd= #{typeCd}
+        </if>
+        <if test="name !=null and name != ''">
+            and t.name= #{name}
+        </if>
+        <if test="paId !=null and paId != ''">
+            and t.pa_id= #{paId}
+        </if>
+        <if test="statusCd !=null and statusCd != ''">
+            and t.status_cd= #{statusCd}
+        </if>
+        <if test="couponId !=null and couponId != ''">
+            and t.coupon_id= #{couponId}
+        </if>
+        <if test="communityId !=null and communityId != ''">
+            and t.community_id= #{communityId}
+        </if>
+        <if test="value !=null and value != ''">
+            and t.value= #{value}
+        </if>
+        <if test="valuePrice !=null and valuePrice != ''">
+            and t.value_price= #{valuePrice}
+        </if>
 
 
-     </select>
+    </select>
 
 </mapper>

+ 18 - 4
service-acct/src/main/java/com/java110/acct/cmd/parkingCoupon/SaveParkingCouponCmd.java

@@ -22,8 +22,10 @@ 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.parking.ParkingAreaDto;
 import com.java110.dto.parkingCoupon.ParkingCouponDto;
 import com.java110.intf.acct.IParkingCouponV1InnerServiceSMO;
+import com.java110.intf.community.IParkingAreaV1InnerServiceSMO;
 import com.java110.po.parkingCoupon.ParkingCouponPo;
 import com.java110.utils.exception.CmdException;
 import com.java110.utils.util.Assert;
@@ -33,6 +35,8 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 
+import java.util.List;
+
 /**
  * 类表述:保存
  * 服务编码:parkingCoupon.saveParkingCoupon
@@ -53,21 +57,22 @@ public class SaveParkingCouponCmd extends Cmd {
     @Autowired
     private IParkingCouponV1InnerServiceSMO parkingCouponV1InnerServiceSMOImpl;
 
+    @Autowired
+    private IParkingAreaV1InnerServiceSMO parkingAreaV1InnerServiceSMOImpl;
+
     @Override
     public void validate(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) {
         Assert.hasKeyAndValue(reqJson, "name", "请求报文中未包含name");
         Assert.hasKeyAndValue(reqJson, "typeCd", "请求报文中未包含typeCd");
         Assert.hasKeyAndValue(reqJson, "communityId", "请求报文中未包含communityId");
         Assert.hasKeyAndValue(reqJson, "paId", "请求报文中未包含paId");
-        if(ParkingCouponDto.TYPE_CD_FREE.equals(reqJson.getString("typeCd"))){
-            reqJson.put("value","9999");
+        if (ParkingCouponDto.TYPE_CD_FREE.equals(reqJson.getString("typeCd"))) {
+            reqJson.put("value", "9999");
         }
         Assert.hasKeyAndValue(reqJson, "value", "请求报文中未包含value");
         Assert.hasKeyAndValue(reqJson, "valuePrice", "请求报文中未包含valuePrice");
 
 
-
-
     }
 
     @Override
@@ -76,6 +81,15 @@ public class SaveParkingCouponCmd extends Cmd {
 
         ParkingCouponPo parkingCouponPo = BeanConvertUtil.covertBean(reqJson, ParkingCouponPo.class);
         parkingCouponPo.setCouponId(GenerateCodeFactory.getGeneratorId(CODE_PREFIX_ID));
+
+        ParkingAreaDto parkingAreaDto = new ParkingAreaDto();
+        parkingAreaDto.setPaId(parkingCouponPo.getPaId());
+        List<ParkingAreaDto> parkingAreaDtos = parkingAreaV1InnerServiceSMOImpl.queryParkingAreas(parkingAreaDto);
+
+        Assert.listOnlyOne(parkingAreaDtos, "停车场不存在");
+
+        parkingCouponPo.setPaName(parkingAreaDtos.get(0).getNum());
+
         int flag = parkingCouponV1InnerServiceSMOImpl.saveParkingCoupon(parkingCouponPo);
 
         if (flag < 1) {

+ 17 - 0
service-acct/src/main/java/com/java110/acct/cmd/parkingCoupon/UpdateParkingCouponCmd.java

@@ -21,17 +21,22 @@ 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.parking.ParkingAreaDto;
 import com.java110.dto.parkingCoupon.ParkingCouponDto;
 import com.java110.intf.acct.IParkingCouponV1InnerServiceSMO;
+import com.java110.intf.community.IParkingAreaV1InnerServiceSMO;
 import com.java110.po.parkingCoupon.ParkingCouponPo;
 import com.java110.utils.exception.CmdException;
 import com.java110.utils.util.Assert;
 import com.java110.utils.util.BeanConvertUtil;
+import com.java110.utils.util.StringUtil;
 import com.java110.vo.ResultVo;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 
+import java.util.List;
+
 
 /**
  * 类表述:更新
@@ -52,6 +57,9 @@ public class UpdateParkingCouponCmd extends Cmd {
     @Autowired
     private IParkingCouponV1InnerServiceSMO parkingCouponV1InnerServiceSMOImpl;
 
+    @Autowired
+    private IParkingAreaV1InnerServiceSMO parkingAreaV1InnerServiceSMOImpl;
+
     @Override
     public void validate(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) {
         Assert.hasKeyAndValue(reqJson, "couponId", "couponId不能为空");
@@ -66,6 +74,15 @@ public class UpdateParkingCouponCmd extends Cmd {
     public void doCmd(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) throws CmdException {
 
         ParkingCouponPo parkingCouponPo = BeanConvertUtil.covertBean(reqJson, ParkingCouponPo.class);
+
+        if(StringUtil.isEmpty(parkingCouponPo.getPaId())) {
+            ParkingAreaDto parkingAreaDto = new ParkingAreaDto();
+            parkingAreaDto.setPaId(parkingCouponPo.getPaId());
+            List<ParkingAreaDto> parkingAreaDtos = parkingAreaV1InnerServiceSMOImpl.queryParkingAreas(parkingAreaDto);
+            Assert.listOnlyOne(parkingAreaDtos, "停车场不存在");
+            parkingCouponPo.setPaName(parkingAreaDtos.get(0).getNum());
+        }
+
         int flag = parkingCouponV1InnerServiceSMOImpl.updateParkingCoupon(parkingCouponPo);
 
         if (flag < 1) {