package com.tofly.feesapi.bjgl.controller_easy;

import com.tofly.feesapi.common.core.ResultRespone;
import com.tofly.feesapi.common.BaseController;
import com.tofly.feesapi.common.dbhelper.DbHelper;
import com.tofly.feesapi.common.enums.SysEnum;
import com.tofly.feesapi.common.model.PageLink;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@AllArgsConstructor
@RequestMapping("/api/meterprofilemgt/dameter")
@Api(tags = "水表档案-用户表计信息接口(easy)")
public class DaMeterEasyController extends BaseController {

    @ApiOperation(value = "通过用户编号查询水表档案列表")
    @PostMapping("/getMeterListByCustomerNo")
    public ResultRespone getMeterListByCustomerNo(@ApiParam(value = "用户编号", required = true) @RequestParam String yhbh) throws Exception {
        DbHelper db = DbHelper.getDbHelper();
        PageLink pg = createPageLink(20, 1);

        String strSql = String.format("select yhbh,cbkh,cbkid,sblb,b.name as sblbmc,a.sbsccj,c.name as sbsccjmc"
                + ",sbxh,d.name as sbxhmc,sbccrq,sbbh,ybdjbz,a.xftbh, a.fjf, a.xfsf, a.ecjybz"
                + ",lgysbz,sjbm,slbl,sjbm1,slbl1,sjbm2,slbl2,"
                + "jfzt,(case when jfzt='1' then '正常' when jfzt='2' then '停用' else '' end) jfztmc"
                + ",cbpl,sbqs,sbkj,sblc,jddj,bjwz,kkbz"
                + ",kkrq,ssfm,ickid,ljfbz,ljfje,wsfbz,a.bz,a.czryxm,a.czrybm,a.czsj,ljffs"
                + ",a.sbzt,e.ccname as sbztmc,a.sbyt,a.szyfbz,a.sbazfs"
                + " from yh_cbkxx a "
                + "left join bm_sblb b on a.sblb=b.code "
                + "left join bm_sbsccj c on a.sbsccj=c.code "
                + "left join bm_sbxh d on a.sbxh=d.code  "
                + "left join sys_child_code e on a.sbzt=e.cccode and pcid='34'"
                + "where yhbh='%s' order by cbkh", yhbh);
        Object obj = db.getPage(pg, strSql, SysEnum.MyBatis.getName());
        // String objString = String.valueOf(obj); // 将对象转换为字符串
        //String lowerCaseObjString = objString.toLowerCase(); // 将字符串转换为小写
        return ResultRespone.success(obj);
    }

}
