pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoPr/PrDivideMapper.java
@@ -49,4 +49,11 @@ * @return */ Integer deleteDivideById(@Param("id") Long id); /** * 根据分水房编号获取所属片区编号 * @param divideId * @return */ Long getBlockIdById(@Param("divideId") Long divideId); } pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoSe/SeClientCardMapper.java
@@ -2,9 +2,11 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.dy.pipIrrGlobal.pojoSe.SeClientCard; import com.dy.pipIrrGlobal.voSe.VoCardInfo; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; import java.util.List; import java.util.Map; /** @@ -56,4 +58,10 @@ */ Map getCardIdAndClientNum(@Param("cardNum") String cardNum); /** * 根据农户主键获取水卡列表 * @param clientId * @return */ List<VoCardInfo> getCardInfoByClientId(@Param("clientId") Long clientId); } pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voSe/VoCardInfo.java
New file @@ -0,0 +1,31 @@ package com.dy.pipIrrGlobal.voSe; import com.dy.common.po.BaseEntity; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; /** * @author ZhuBaoMin * @date 2023-12-27 19:22 * @LastEditTime 2023-12-27 19:22 * @Description */ @Data @Schema(title = "IC卡视图对象") public class VoCardInfo implements BaseEntity { private static final long serialVersionUID = 1L; @Schema(title = "水卡编号") private Long cardNum; @Schema(title = "卡片类型") private String cardType; @Schema(title = "余额") private Float money; @Schema(title = "水卡状态") private String state; } pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voSe/VoClient.java
@@ -23,6 +23,9 @@ @Schema(title = "ID") private Long id; @Schema(title = "农户ID") private String clientId; @Schema(title = "农户姓名") private String name; pipIrr-platform/pipIrr-global/src/main/resources/mapper/BaDistrictMapper.xml
@@ -169,7 +169,7 @@ <!--根据级别获取行政区划列表--> <select id="getDistrictgsByLevel" resultType="java.util.Map"> SELECT id, CAST(id AS char) AS id, name FROM ba_district WHERE `level` = ${level} </select> @@ -177,7 +177,7 @@ <!--根据父ID获取行政区划列表--> <select id="getDistrictsBySupperId" resultType="java.util.Map"> SELECT id, CAST(id AS char) AS id, name FROM ba_district WHERE supperId = ${supperId} </select> pipIrr-platform/pipIrr-global/src/main/resources/mapper/PrDivideMapper.xml
@@ -297,4 +297,9 @@ </where> </update> <!--根据分水房编号获取所属片区编号--> <select id="getBlockIdById" resultType="java.lang.Long"> SELECT blockId FROM pr_divide WHERE id = ${divideId}} </select> </mapper> pipIrr-platform/pipIrr-global/src/main/resources/mapper/SeClientCardMapper.xml
@@ -257,4 +257,19 @@ remarks = #{remarks,jdbcType=VARCHAR} where id = #{id,jdbcType=BIGINT} </update> <!--根据农户主键获取水卡列表--> <select id="getCardInfoByClientId" resultType="com.dy.pipIrrGlobal.voSe.VoCardInfo"> SELECT cardNum, '用户卡' AS cardType, money, (CASE WHEN state = 1 THEN "正常" WHEN state = 2 THEN "已注销" ELSE "已挂失" END) AS state FROM se_client_card WHERE clientId = ${clientId} </select> </mapper> pipIrr-platform/pipIrr-global/src/main/resources/mapper/SeClientMapper.xml
@@ -330,6 +330,7 @@ <select id="getClients" resultType="com.dy.pipIrrGlobal.voSe.VoClient"> SELECT (@i:=@i+1) AS id, CAST(id AS char) AS clientId, name, clientNum, phone, pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/divide/DivideSv.java
@@ -117,4 +117,13 @@ public Integer updateByPrimaryKey(PrDivide po) { return prDivideMapper.updateByPrimaryKey(po); } /** * 根据分水房编号获取所属片区编号 * @param divideId 分水房ID * @return 所属片区ID */ public Long getBlockIdById(Long divideId) { return prDivideMapper.getBlockIdById(divideId); } } pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/clientCard/ClientCardCtrl.java
New file @@ -0,0 +1,61 @@ package com.dy.pipIrrSell.clientCard; import com.dy.common.aop.SsoAop; import com.dy.common.webUtil.BaseResponse; import com.dy.common.webUtil.BaseResponseUtils; import com.dy.common.webUtil.QueryResultVo; import com.dy.common.webUtil.ResultCodeMsg; import com.dy.pipIrrGlobal.pojoBa.BaClient; import com.dy.pipIrrGlobal.voSe.VoCardInfo; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.tags.Tag; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.http.MediaType; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import java.util.List; /** * @author ZhuBaoMin * @date 2023-12-27 19:36 * @LastEditTime 2023-12-27 19:36 * @Description */ @Slf4j @Tag(name = "农户水卡", description = "农户水卡") @RestController @RequestMapping(path="clientcard") @RequiredArgsConstructor public class ClientCardCtrl { private final ClientCardSv clientCardSv; @Operation(summary = "获得全部水卡", description = "返回全部水卡数据") @ApiResponses(value = { @ApiResponse( responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE, description = "返回一页农户数据(BaseResponse.content:QueryResultVo[{}])", content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = BaClient.class))} ) }) @GetMapping(path = "clientcard/{clientId}") @SsoAop() public BaseResponse<QueryResultVo<List<VoCardInfo>>> get(@PathVariable("clientId") Long clientId){ try { List<VoCardInfo> list = clientCardSv.getCardInfoByClientId(clientId); return BaseResponseUtils.buildSuccess(list); } catch (Exception e) { log.error("查询农户异常", e); return BaseResponseUtils.buildException(e.getMessage()) ; } } } pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/clientCard/ClientCardSv.java
@@ -2,11 +2,15 @@ import com.dy.pipIrrGlobal.daoSe.SeClientCardMapper; import com.dy.pipIrrGlobal.pojoSe.SeClientCard; import com.dy.pipIrrGlobal.voSe.VoCardInfo; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Optional; /** * @author ZhuBaoMin @@ -65,4 +69,18 @@ public Integer UpdateClientCard(SeClientCard po) { return seClientCardMapper.updateByPrimaryKeySelective(po); } /** * 根据农户主键获取水卡列表 * @param clientId * @return */ public List<VoCardInfo> getCardInfoByClientId(Long clientId){ List<VoCardInfo> list = Optional.ofNullable(seClientCardMapper.getCardInfoByClientId(clientId)).orElse(new ArrayList<>()); if(list.size() > 0) { return list; }else { return new ArrayList<>(); } } }