package com.imed.costaccount.web; import com.imed.costaccount.common.exception.CostException; import com.imed.costaccount.common.util.PageUtils; import com.imed.costaccount.common.util.Result; import com.imed.costaccount.model.dto.StartDTO; import com.imed.costaccount.model.vo.AfterAllocationFormVO; import com.imed.costaccount.model.vo.CollectDataFormVO; import com.imed.costaccount.service.AllocationService; import com.imed.costaccount.service.CostCostingGroupService; import io.swagger.annotations.*; import org.springframework.web.bind.annotation.*; import javax.validation.Valid; import java.util.List; /** * 成本归集 * * @author KCYG * @date 2021-08-12 11:00:23 */ @Api(tags = "成本分摊") @RestController @RequestMapping("/costAccount/costcostinggroup") public class CostCostingGroupController extends AbstractController { private final CostCostingGroupService costCostingGroupService; private final AllocationService allocationService; public CostCostingGroupController(CostCostingGroupService costCostingGroupService, AllocationService allocationService) { this.costCostingGroupService = costCostingGroupService; this.allocationService = allocationService; } @ApiOperation("成本分摊前数据列表") @GetMapping("/queryStartAllocation") @ApiImplicitParams({ @ApiImplicitParam(name = "current", value = "当前页", required = true), @ApiImplicitParam(name = "pageSize", value = "当前页大小", required = true), @ApiImplicitParam(name = "responsibilityCode", value = "责任中心代码", required = false), @ApiImplicitParam(name = "accountCode", value = "会计中心代码"), @ApiImplicitParam(name = "date", value = "年月yyyy-MM")} ) public Result queryStartAllocation(@RequestParam(value = "current", defaultValue = "1") Integer current, @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize, @RequestParam(value = "responsibilityCode", required = false) String responsibilityCode, @RequestParam(value = "accountCode", required = false) String accountCode, @RequestParam(value = "date") String date) { // 简单校验时间格式 这里要求的是yyyy-MM-dd if (date.length() != 7) { throw new CostException("时间格式不正确,这里要求yyyy-MM 格式"); } PageUtils pageUtils = costCostingGroupService.queryStartAllocation(current, pageSize, responsibilityCode, accountCode, date, getHospId()); return Result.ok(pageUtils); } @ApiOperation("成本分摊列表") @GetMapping("/allocationList") @ApiImplicitParams({ @ApiImplicitParam(name = "current", value = "当前页", required = true), @ApiImplicitParam(name = "pageSize", value = "当前页大小", required = true), @ApiImplicitParam(name = "date", value = "年月yyyy-MM-dd", required = true) }) public Result allocationList(@RequestParam(value = "current", defaultValue = "1", required = false) Integer current, @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize, @RequestParam(value = "date", required = false) String date) { PageUtils pageUtils = costCostingGroupService.queryAllocation(current, pageSize, date, getHospId()); return Result.ok(pageUtils); } @ApiOperation("开始分摊") @PostMapping("/startAllocation") public Result startAllocation(@RequestBody @Valid StartDTO startDTO) { // costCostingGroupService.startAllocation(startDTO, getHospId()); allocationService.startAllocation(startDTO, getHospId()); return Result.ok(); } @ApiOperation("分摊后列表") @GetMapping("/queryAfterAllocation") @ApiImplicitParams({ @ApiImplicitParam(name = "year", value = "年月日(yyyy-MM-dd)"), @ApiImplicitParam(name = "responsibilityCode", value = "责任中心代码"), @ApiImplicitParam(name = "current", value = "每页数据大小"), @ApiImplicitParam(name = "pageSize", value = "每页数据大小") }) public Result queryAfterAllocation(@RequestParam(value = "year", required = false) String year, @RequestParam(value = "responsibilityCode", required = false) String responsibilityCode, @RequestParam(value = "current", defaultValue = "1", required = false) Integer current, @RequestParam(value = "pageSize", defaultValue = "10", required = false) Integer pageSize) { PageUtils pageUtils = allocationService.queryAfterAllocation(year, responsibilityCode, current, pageSize, getHospId()); return Result.ok(pageUtils); } @ApiOperation("分摊后报表") @GetMapping("/queryAfterAllocationForm") @ApiImplicitParams({ @ApiImplicitParam(name = "year", value = "年月日(yyyy-MM-dd)"), @ApiImplicitParam(name = "responsibilityCode", value = "责任中心代码") }) public Result queryAfterAllocationForm(@RequestParam(value = "year", required = false) String year, @RequestParam(value = "responsibilityCode", required = false) String responsibilityCode) { return Result.ok(allocationService.queryAfterAllocationForm(year, responsibilityCode, getHospId())); } @ApiOperation("分摊后报表输出") @GetMapping("/afterAllocationFormList") public Result afterAllocationFormList(@RequestParam(value = "date", required = false) @ApiParam(name = "date", value = "年月日(yyyy-MM-dd)") String date) { List list = allocationService.afterAllocationFormList(date, getHospId()); PageUtils pageUtils = new PageUtils(list, 0, 0, 0); return Result.ok(pageUtils); } }