package com.kcim.web;

import com.kcim.common.util.Result;
import com.kcim.service.EmpCostImportService;
import com.kcim.service.PatientInfoImportService;
import com.kcim.service.PatientItemImportService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;

/**
 * @program: CostAccount
 * @description: 月度信息采集
 * @author: Wang.YS
 * @create: 2023-10-18 19:21
 **/
@Api(tags = "月度信息采集")
@RestController
@RequestMapping("computeImport")
@AllArgsConstructor
public class ComputeImportController {
    EmpCostImportService empCostImportService;
    @ApiOperation("月度信息采集-人事成本数据导入-获取导入列表")
    @GetMapping("getEmpCostList")
    public Result getEmpCostList(@RequestParam(required = false,name = "current",defaultValue = "1") Integer current,
                                 @RequestParam(required = false,name = "pageSize",defaultValue = "10") Integer pageSize,
                                 @RequestParam String computeDate,
                                 @RequestParam(required = false,name = "filter",defaultValue = "")String filter){

        return Result.ok(empCostImportService.getEmpCostList(current,pageSize,computeDate,filter));
    }
    @ApiOperation("月度信息采集-人事成本数据导入-获取导出模版")
    @GetMapping("exportEmpCostList")
    public Result exportEmpCostList(HttpServletResponse response){
        return Result.ok(empCostImportService.exportEmpCostList(response));
    }
    @ApiOperation("月度信息采集-人事成本数据导入-导入数据")
    @PostMapping("importEmpCostList")
    public Result importEmpCostList(@RequestPart("computeDate")String computeDate,
                                    @RequestPart("file") MultipartFile file){
        empCostImportService.importEmpCostList(computeDate,file);
        return Result.ok();
    }

    PatientItemImportService patientItemImportService;
    @ApiOperation("月度信息采集-患者收费项目导入-获取患者收费项目列表")
    @GetMapping("getPatientItemList")
    public Result getPatientItemList(@RequestParam(required = false,name = "current",defaultValue = "1") Integer current,
                                     @RequestParam(required = false,name = "pageSize",defaultValue = "10") Integer pageSize,
                                     @RequestParam String computeDate,
                                     @RequestParam(required = false,name = "itemType",defaultValue = "")String itemType,
                                     @RequestParam(required = false,name = "departmentName",defaultValue = "")String departmentName,
                                     @RequestParam String patientNo,
                                     @RequestParam(required = false)String filter){

        return Result.ok(patientItemImportService.getPatientItemList(current,pageSize,computeDate,itemType,departmentName,patientNo,filter));
    }
    @ApiOperation("月度信息采集-患者收费项目导入-获取患者收费项目模版")
    @GetMapping("exportPatientItem")
    public Result exportPatientItem(HttpServletResponse response){
        return Result.ok(patientItemImportService.exportPatientItem(response));
    }
    @ApiOperation("月度信息采集-患者收费项目导入-导入患者收费项目数据")
    @PostMapping("importPatientItem")
    public Result importPatientItem(@RequestPart("computeDate")String computeDate,
                                    @RequestPart("file") MultipartFile file){
        patientItemImportService.importPatientItem(computeDate,file);
        return Result.ok();
    }

    @ApiOperation("月度信息采集-患者收费项目导入-获取患者收费项目总金额")
    @GetMapping("getComputeTotal")
    public Result getComputeTotal(@RequestParam("computeDate")String computeDate,
                                  @RequestParam(required = false,name = "itemType",defaultValue = "")String itemType,
                                  @RequestParam(required = false,name = "departmentName",defaultValue = "")String departmentName){
        return Result.ok(patientItemImportService.getComputeTotal(computeDate,itemType,departmentName));
    }

    PatientInfoImportService patientInfoImportService;
    @ApiOperation("月度信息采集-患者信息导入-获取导入列表")
    @GetMapping("getPatientInfoList")
    public Result getPatientInfoList(@RequestParam(required = false,name = "current",defaultValue = "1") Integer current,
                                     @RequestParam(required = false,name = "pageSize",defaultValue = "10") Integer pageSize,
                                     @RequestParam String computeDate,
                                     @RequestParam(required = false,name = "departmentName",defaultValue = "")String departmentName,
                                     @RequestParam(required = false,name = "patientName",defaultValue = "")String patientName,
                                     @RequestParam(required = false)String filter,
                                     @RequestParam String departmentCode){

        return Result.ok(patientInfoImportService.getPatientInfoList(current,pageSize,computeDate,departmentName,patientName,filter,departmentCode));
    }
    @ApiOperation("月度信息采集-患者信息导入-获取导出模版")
    @GetMapping("exportPatientInfo")
    public Result exportPatientInfo(HttpServletResponse response){
        return Result.ok(patientInfoImportService.exportPatientInfo(response));
    }
    @ApiOperation("月度信息采集-患者信息导入-导入数据")
    @PostMapping("importPatientInfo")
    public Result importPatientInfo(@RequestPart("computeDate")String computeDate,
                                    @RequestPart("file") MultipartFile file){
        patientInfoImportService.importPatientInfo(computeDate,file);
        return Result.ok();
    }

}
