Administrator
2023-12-27 0fd777e6de7c058accfba355ec419959927e0cb2
pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/client/ClientCtrl.java
@@ -40,6 +40,11 @@
public class ClientCtrl {
    private final ClientSv clientSv;
    /**
     * 获取农户列表
     * @param vo
     * @return
     */
    @Operation(summary = "获得一页农户", description = "返回一页农户数据")
    @ApiResponses(value = {
            @ApiResponse(
@@ -61,6 +66,63 @@
        }
    }
    /**
     * 获取交易记录
     * @param vo
     * @return
     */
    @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 = "getOperates")
    @SsoAop()
    public BaseResponse<Map> getOperates(QueryOperate vo){
        try {
           Map res = clientSv.getOperates(vo);
            return BaseResponseUtils.buildSuccess(res);
        } catch (Exception e) {
            log.error("查询交易记录异常", e);
            return BaseResponseUtils.buildException(e.getMessage()) ;
        }
    }
    /**
     * 获取交易汇总记录
     * @param vo
     * @return
     */
    @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 = "getStatistics")
    @SsoAop()
    public BaseResponse<Map> getStatistics(QueryStatistic vo){
        try {
            Map res = clientSv.getStatistics(vo);
            return BaseResponseUtils.buildSuccess(res);
        } catch (Exception e) {
            log.error("查询交易汇总记录异常", e);
            return BaseResponseUtils.buildException(e.getMessage()) ;
        }
    }
    /**
     * 根据主键获取一个农户对象
     * @param id
     * @return
     */
    @Operation(summary = "获得一个农户", description = "返回一个农户数据")
    @ApiResponses(value = {
            @ApiResponse(
@@ -83,6 +145,12 @@
    }
    /**
     * 添加一个农户对象
     * @param po
     * @param bindingResult
     * @return
     */
    @Operation(summary = "添加农户记录", description = "添加农户记录")
    @ApiResponses(value = {
            @ApiResponse(
@@ -130,9 +198,21 @@
        Long districtNum = Long.parseLong(provinceNum + cityNum + district8);
        String districtTitle = countryName + townName + villageName;
        // 生成虚拟卡号
        Long virtualId = Optional.ofNullable(clientSv.getMa1xVirtualId()).orElse(0L);
        if(virtualId == 0) {
            virtualId = 1000000000L;
        }else {
            virtualId = virtualId + 1;
            if(virtualId > 10000000000L) {
                return BaseResponseUtils.buildFail("虚拟卡号超限");
            }
        }
        SeClient seClient = DtoClientToSeClient.INSTANCT.po2vo(po);
        seClient.setCountyid(countryId);
        seClient.setTownid(townId);
        seClient.setVirtualid(virtualId);
        seClient.setClientnum(clientNum);
        seClient.setDistrictnum(districtNum);
        seClient.setDistricttitle(districtTitle);
@@ -176,7 +256,7 @@
    }
    /**
     * 修改农户对象
     * 修改农户对象(虚拟卡号、禁止标志、逻辑删除标识不参与修改)
     * @param po 农户对象
     * @param bindingResult
     * @return
@@ -236,13 +316,10 @@
        seClient.setDistricttitle(districtTitle);
        Date operateTime = new Date();
        seClient.setOperatedt(operateTime);
        //
        //seClient.setDisabled((byte)0);
        //seClient.setDeleted((byte)0);
        Integer rec = Optional.ofNullable(clientSv.updateByPrimaryKey(seClient)).orElse(0);
        if(rec == 0) {
            return BaseResponseUtils.buildFail("添加农户失败");
            return BaseResponseUtils.buildFail("农户修改失败");
        }
        return BaseResponseUtils.buildSuccess(true) ;
    }
@@ -276,4 +353,28 @@
            return BaseResponseUtils.buildException(e.getMessage()) ;
        }
    }
    /**
     * 获取用水方式列表
     * @param
     * @return
     */
    @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 = "/watertypes")
    @SsoAop()
    public BaseResponse<QueryResultVo<List<Map<String, Object>>>> getWaterTypes(){
        List<Map<String, Object>> map_WaterTypes = Optional.ofNullable(clientSv.getWaterTypes()).orElse(new ArrayList<>());
        if(map_WaterTypes == null || map_WaterTypes.size() == 0) {
            return BaseResponseUtils.buildFail("没有用水方式") ;
        }
        return BaseResponseUtils.buildSuccess(map_WaterTypes);
    }
}