package thyyxxk.webserver.controller.zygl;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import thyyxxk.webserver.config.exception.ExceptionEnum;
import thyyxxk.webserver.entity.ResultVo;
import thyyxxk.webserver.entity.zygl.ZyDailySettlementVo;
import thyyxxk.webserver.entity.zygl.ZyDayclosingRecord;
import thyyxxk.webserver.service.zygl.ZyDailySettlementService;
import thyyxxk.webserver.utils.DateUtil;
import thyyxxk.webserver.utils.ResultVoUtil;
import thyyxxk.webserver.utils.TokenUtil;

import javax.annotation.Resource;
import java.util.List;

@Slf4j
@RequestMapping("/zyDaily")
@RestController()
public class ZyDailySettlementController {
    @Resource
    private ZyDailySettlementService zyDailySettlementService;
    /**
     * 获取未结算日结报表的明细
     *
     * @return
     */
    @PostMapping(value = "/getZyDailySettlementVo")
    public ResultVo<ZyDailySettlementVo> getZyDailySettlementVo(@RequestBody ZyDayclosingRecord param) {
        ZyDailySettlementVo zyDailySettlementVo = zyDailySettlementService.getZyDailySettlementVo(param);
        return ResultVoUtil.success(zyDailySettlementVo);
    }

    /**
     * 住院报表日结
     * @return
     */
    @GetMapping(value = "/dayClosing")
    public ResultVo dayClosing(String dateEnd) {
        zyDailySettlementService.dayClosing(DateUtil.parse(dateEnd, "yyyy-MM-dd HH:mm:ss"), TokenUtil.getInstance().getTokenUserId());
        return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_EL_MESSAGE,"住院日结成功");
    }

    /**
     * 查询医院
     * @return
     */
    @GetMapping(value = "/queryHospitalName")
    public ResultVo queryHospitalName() {
        return ResultVoUtil.success(zyDailySettlementService.queryHospitalName());
    }

    @PostMapping("/queryZyDayclosingRecord")
    public ResultVo<List<ZyDayclosingRecord>> queryZyDayclosingRecord(@RequestBody ZyDayclosingRecord param) {
        return ResultVoUtil.success(zyDailySettlementService.queryZyDayclosingRecord(param));
    }
}
