package thyyxxk.webserver.controller.medicalinsurance;

import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import thyyxxk.webserver.config.auth.PassToken;
import thyyxxk.webserver.entity.ResultVo;
import thyyxxk.webserver.entity.datamodify.GetDropdownBox;
import thyyxxk.webserver.entity.datamodify.TYbSetModifyTime;
import thyyxxk.webserver.entity.datamodify.TYbSetlModifyReq;
import thyyxxk.webserver.entity.medicalinsurance.inpatient.ZyInactpatient;
import thyyxxk.webserver.entity.medicalinsurance.setllistupld.PatientBldInfo;
import thyyxxk.webserver.entity.medicalinsurance.setllistupld.UpldCollection;
import thyyxxk.webserver.entity.medicalinsurance.setllistupldTemp.UpldCollectionTemp;
import thyyxxk.webserver.entity.querydata.ConsumablesStatistics;
import thyyxxk.webserver.entity.querydata.JieSuanDanChaXun;
import thyyxxk.webserver.entity.querydata.SiSetlinfoTemp;
import thyyxxk.webserver.service.LoginService;
import thyyxxk.webserver.service.medicalinsurance.SetlListUpldService;

import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 描述： 结算单上传
 * </p>
 *
 * @author xc
 * @date 2021-12-09 10:45
 */
@RestController
@RequestMapping("/setlListUpld")
public class SetlListUpldController {

    private final SetlListUpldService service;

    public SetlListUpldController(SetlListUpldService service) {
        this.service = service;
    }

    @PostMapping("/upldSetlList")
    @PassToken
    public ResultVo<String> upldSetlList(@RequestBody List<SiSetlinfoTemp> siPatInfos) {
        return service.upldSetlListBatch(siPatInfos);
    }

    @PostMapping("/upldSetlListTimes")
    public ResultVo<String> upldSetlListTimes(@RequestBody JieSuanDanChaXun param) {
        return service.upldSetlListTimes(param);
    }

    @GetMapping("/getMedType")
    public ResultVo<List<Object>> getMedType() {
        return service.getMedType();
    }

    @GetMapping("/getMedChrgitmType")
    public ResultVo<List<Object>> getMedChrgitmType() {
        return service.getMedChrgitmType();
    }

    @GetMapping("/getFundPayType")
    public ResultVo<List<Object>> getFundPayType() {
        return service.getFundPayType();
    }

    @PostMapping("/huoQuJieSuanRenYuan")
    public ResultVo<IPage<SiSetlinfoTemp>> huoQuJieSuanRenYuan(@RequestBody JieSuanDanChaXun param) {
        return service.huoQuJieSuanRenYuan(param);
    }

    @GetMapping("/getUploadInfo")
    @PassToken
    public ResultVo<UpldCollection> getUploadInfo(@RequestParam("patNo") String patNo,
                                                  @RequestParam("times") Integer times,
                                                  @RequestParam("ledgerSn") Integer ledgerSn) throws Exception {
        return service.getUploadInfo(patNo, times, ledgerSn);
    }

    @GetMapping("/daYingShangChuanJieSuanDan")
    @PassToken
    public ResultVo<UpldCollectionTemp> daYingShangChuanJieSuanDan(@RequestParam("patNo") String patNo,
                                                                   @RequestParam("times") Integer times,
                                                                   @RequestParam("ledgerSn") Integer ledgerSn) throws Exception {
        return service.daYingShangChuanJieSuanDan(patNo, times, ledgerSn);
    }


    @PostMapping("/exportExcel")
    public void exportExcel(HttpServletResponse response,
                            @RequestBody @Validated JieSuanDanChaXun param) {
        service.exportExcel(response, param);
    }

    @GetMapping("/jieSuanDanKeXiuGaiXinXi")
    public ResultVo<ZyInactpatient> jieSuanDanKeXiuGaiXinXi(@RequestParam("patNo") String patNo,
                                                            @RequestParam("times") Integer times,
                                                            @RequestParam("ledgerSn") Integer ledgerSn) {
        return service.jieSuanDanKeXiuGaiXinXi(patNo, times, ledgerSn);
    }


    @GetMapping("/shouShuBianMa")
    public ResultVo<IPage<GetDropdownBox>> shouShuBianMa(@RequestParam("content") String content,
                                                         @RequestParam("currentPage") long currentPage) {
        return service.shouShuBianMa(content, currentPage);
    }

    @PostMapping("/setlModifyReq")
    public ResultVo<String> setlModifyReq(@RequestBody ZyInactpatient param) {
        return service.setlModifyReq(param);
    }

    @PostMapping("/setlUploadAudit")
    public ResultVo<String> setlUploadAudit(@RequestBody TYbSetlModifyReq param) {
        return service.setlUploadAudit(param.getId(), param.getAuditFlag(), param.getAuditRemark(), param.getAuditStaff(), param.getAuditName());
    }

    @GetMapping("/xianZhiShiJian")
    public ResultVo<TYbSetModifyTime> xianZhiShiJian() {
        return service.xianZhiShiJian();
    }

    @GetMapping("/sheZhiShiJian")
    public ResultVo<String> sheZhiShiJian(@RequestParam("startTime") String startTime,
                                          @RequestParam("endTime") String endTime,
                                          @RequestParam("opId") String opId) {
        return service.sheZhiShiJian(startTime, endTime, opId);
    }

    @GetMapping("/getHuanZheFeiYong")
    public ResultVo<List<Map<String, String>>> getHuanZheFeiYong(@RequestParam("patNo") String patNo,
                                                                 @RequestParam("times") Integer times) {
        return service.getHuanZheFeiYong(patNo, times);
    }

    @GetMapping("/xiuGaiGuanChuangYiShen")
    public ResultVo<String> xiuGaiGuanChuangYiShen(@RequestParam("patNo") String patNo,
                                                   @RequestParam("times") Integer times,
                                                   @RequestParam("code") String code) {
        return service.xiuGaiGuanChuangYiShen(patNo, times, code);
    }

    @GetMapping("/modifyMedicalCategory")
    public ResultVo<String> modifyMedicalCategory(@RequestParam("iptMenType") String iptMenType,
                                                  @RequestParam("setlId") String setlId) {
        return service.modifyMedicalCategory(iptMenType, setlId);
    }

    @PostMapping("/addOrModifyBloodTransfusionVolume")
    public ResultVo<String> addOrModifyBloodTransfusionVolume(@RequestBody PatientBldInfo param) {
        return service.addOrModifyBloodTransfusionVolume(param);
    }

    @GetMapping("/removeBloodTransfusion")
    public ResultVo<String> removeBloodTransfusion(@RequestParam("id") Integer id) {
        return service.removeBloodTransfusion(id);
    }

    @PostMapping("/exportAutoUploadInfo")
    public void exportAutoUploadInfo(HttpServletResponse response, @RequestBody ConsumablesStatistics param) {
        service.exportAutoUploadInfo(response, param.getStartTime(), param.getEndTime());
    }

}
