|
|
@@ -0,0 +1,199 @@
|
|
|
+/*
|
|
|
+ * Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
|
|
|
+ *
|
|
|
+ * Redistribution and use in source and binary forms, with or without
|
|
|
+ * modification, are permitted provided that the following conditions are met:
|
|
|
+ *
|
|
|
+ * Redistributions of source code must retain the above copyright notice,
|
|
|
+ * this list of conditions and the following disclaimer.
|
|
|
+ * Redistributions in binary form must reproduce the above copyright
|
|
|
+ * notice, this list of conditions and the following disclaimer in the
|
|
|
+ * documentation and/or other materials provided with the distribution.
|
|
|
+ * Neither the name of the dreamlu.net developer nor the names of its
|
|
|
+ * contributors may be used to endorse or promote products derived from
|
|
|
+ * this software without specific prior written permission.
|
|
|
+ * Author: Chill 庄骞 (smallchill@163.com)
|
|
|
+ */
|
|
|
+package org.springblade.los.finance.agreement.controller;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import io.swagger.annotations.ApiParam;
|
|
|
+import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
|
|
+import lombok.AllArgsConstructor;
|
|
|
+
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import javax.validation.Valid;
|
|
|
+
|
|
|
+import org.springblade.core.excel.util.ExcelUtil;
|
|
|
+import org.springblade.core.mp.support.Condition;
|
|
|
+import org.springblade.core.mp.support.Query;
|
|
|
+import org.springblade.core.secure.utils.AuthUtil;
|
|
|
+import org.springblade.core.tool.api.R;
|
|
|
+import org.springblade.core.tool.utils.BeanUtil;
|
|
|
+import org.springblade.core.tool.utils.Func;
|
|
|
+import org.springblade.los.finance.agreement.dto.AgreementPriceExcel;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import org.springblade.los.finance.agreement.entity.AgreementPrice;
|
|
|
+import org.springblade.los.finance.agreement.vo.AgreementPriceVO;
|
|
|
+import org.springblade.los.finance.agreement.service.IAgreementPriceService;
|
|
|
+import org.springblade.core.boot.ctrl.BladeController;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 物流-业务-协议价管理主表 控制器
|
|
|
+ *
|
|
|
+ * @author BladeX
|
|
|
+ * @since 2023-10-10
|
|
|
+ */
|
|
|
+@RestController
|
|
|
+@AllArgsConstructor
|
|
|
+@RequestMapping("/agreementprice")
|
|
|
+@Api(value = "物流-业务-协议价管理主表", tags = "物流-业务-协议价管理主表接口")
|
|
|
+public class AgreementPriceController extends BladeController {
|
|
|
+
|
|
|
+ private final IAgreementPriceService agreementPriceService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 详情
|
|
|
+ */
|
|
|
+ @GetMapping("/detail")
|
|
|
+ @ApiOperationSupport(order = 1)
|
|
|
+ @ApiOperation(value = "详情", notes = "传入agreementPrice")
|
|
|
+ public R<AgreementPrice> detail(AgreementPrice agreementPrice) {
|
|
|
+ AgreementPrice detail = agreementPriceService.detail(agreementPrice);
|
|
|
+ return R.data(detail);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 分页 物流-业务-协议价管理主表
|
|
|
+ */
|
|
|
+ @GetMapping("/list")
|
|
|
+ @ApiOperationSupport(order = 2)
|
|
|
+ @ApiOperation(value = "分页", notes = "传入agreementPrice")
|
|
|
+ public R<IPage<AgreementPrice>> list(AgreementPrice agreementPrice, Query query) {
|
|
|
+ LambdaQueryWrapper<AgreementPrice> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ lambdaQueryWrapper.eq(AgreementPrice::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(AgreementPrice::getIsDeleted, 0)
|
|
|
+ .like(ObjectUtils.isNotNull(agreementPrice.getBillNo()), AgreementPrice::getBillNo, agreementPrice.getBillNo())
|
|
|
+ .like(ObjectUtils.isNotNull(agreementPrice.getAgreementNo()), AgreementPrice::getAgreementNo, agreementPrice.getAgreementNo())
|
|
|
+ .eq(ObjectUtils.isNotNull(agreementPrice.getCorpId()), AgreementPrice::getCorpId, agreementPrice.getCorpId())
|
|
|
+ .eq(ObjectUtils.isNotNull(agreementPrice.getCreditLevel()), AgreementPrice::getCreditLevel, agreementPrice.getCreditLevel())
|
|
|
+ .like(ObjectUtils.isNotNull(agreementPrice.getSignedId()), AgreementPrice::getSignedId, agreementPrice.getSignedId())
|
|
|
+ .lt(ObjectUtils.isNotNull(agreementPrice.getEffectiveDate()), AgreementPrice::getEffectiveDate, agreementPrice.getEffectiveDate())
|
|
|
+ .gt(ObjectUtils.isNotNull(agreementPrice.getEffectiveDate()), AgreementPrice::getEffectiveDate, agreementPrice.getEffectiveDate())
|
|
|
+ .orderByDesc(AgreementPrice::getCreateTime);
|
|
|
+ IPage<AgreementPrice> pages = agreementPriceService.page(Condition.getPage(query), lambdaQueryWrapper);
|
|
|
+ return R.data(pages);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 自定义分页 物流-业务-协议价管理主表
|
|
|
+ */
|
|
|
+ @GetMapping("/page")
|
|
|
+ @ApiOperationSupport(order = 3)
|
|
|
+ @ApiOperation(value = "分页", notes = "传入agreementPrice")
|
|
|
+ public R<IPage<AgreementPriceVO>> page(AgreementPriceVO agreementPrice, Query query) {
|
|
|
+ IPage<AgreementPriceVO> pages = agreementPriceService.selectAgreementPricePage(Condition.getPage(query), agreementPrice);
|
|
|
+ return R.data(pages);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 新增 物流-业务-协议价管理主表
|
|
|
+ */
|
|
|
+ @PostMapping("/save")
|
|
|
+ @ApiOperationSupport(order = 4)
|
|
|
+ @ApiOperation(value = "新增", notes = "传入agreementPrice")
|
|
|
+ public R save(@Valid @RequestBody AgreementPrice agreementPrice) {
|
|
|
+ return R.status(agreementPriceService.save(agreementPrice));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改 物流-业务-协议价管理主表
|
|
|
+ */
|
|
|
+ @PostMapping("/update")
|
|
|
+ @ApiOperationSupport(order = 5)
|
|
|
+ @ApiOperation(value = "修改", notes = "传入agreementPrice")
|
|
|
+ public R update(@Valid @RequestBody AgreementPrice agreementPrice) {
|
|
|
+ return R.status(agreementPriceService.updateById(agreementPrice));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 新增或修改 物流-业务-协议价管理主表
|
|
|
+ */
|
|
|
+ @PostMapping("/submit")
|
|
|
+ @ApiOperationSupport(order = 6)
|
|
|
+ @ApiOperation(value = "新增或修改", notes = "传入agreementPrice")
|
|
|
+ public R submit(@Valid @RequestBody AgreementPrice agreementPrice) {
|
|
|
+ return agreementPriceService.submit(agreementPrice);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除 物流-业务-协议价管理主表
|
|
|
+ */
|
|
|
+ @PostMapping("/remove")
|
|
|
+ @ApiOperationSupport(order = 8)
|
|
|
+ @ApiOperation(value = "删除", notes = "传入ids")
|
|
|
+ public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
|
|
|
+ return R.status(agreementPriceService.removeByIds(Func.toLongList(ids)));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 导出 基础资料-币种
|
|
|
+ */
|
|
|
+ @GetMapping("/exportAgreementPrice")
|
|
|
+ @ApiOperationSupport(order = 3)
|
|
|
+ @ApiOperation(value = "导出 物流-业务-协议价管理主表", notes = "传入AgreementPrice")
|
|
|
+ public void exportAgreementPrice(AgreementPrice agreementPrice, HttpServletResponse response) {
|
|
|
+ LambdaQueryWrapper<AgreementPrice> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ lambdaQueryWrapper.eq(AgreementPrice::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(AgreementPrice::getIsDeleted, 0)
|
|
|
+ .like(ObjectUtils.isNotNull(agreementPrice.getBillNo()), AgreementPrice::getBillNo, agreementPrice.getBillNo())
|
|
|
+ .like(ObjectUtils.isNotNull(agreementPrice.getAgreementNo()), AgreementPrice::getAgreementNo, agreementPrice.getAgreementNo())
|
|
|
+ .eq(ObjectUtils.isNotNull(agreementPrice.getCorpId()), AgreementPrice::getCorpId, agreementPrice.getCorpId())
|
|
|
+ .eq(ObjectUtils.isNotNull(agreementPrice.getCreditLevel()), AgreementPrice::getCreditLevel, agreementPrice.getCreditLevel())
|
|
|
+ .like(ObjectUtils.isNotNull(agreementPrice.getSignedId()), AgreementPrice::getSignedId, agreementPrice.getSignedId())
|
|
|
+ .lt(ObjectUtils.isNotNull(agreementPrice.getEffectiveDate()), AgreementPrice::getEffectiveDate, agreementPrice.getEffectiveDate())
|
|
|
+ .gt(ObjectUtils.isNotNull(agreementPrice.getEffectiveDate()), AgreementPrice::getEffectiveDate, agreementPrice.getEffectiveDate())
|
|
|
+ .orderByDesc(AgreementPrice::getCreateTime);
|
|
|
+ List<AgreementPrice> agreementPriceList = agreementPriceService.list(lambdaQueryWrapper);
|
|
|
+ ExcelUtil.export(response, "协议价管理", "协议价", BeanUtil.copy(agreementPriceList, AgreementPriceExcel.class), AgreementPriceExcel.class);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 导出模板
|
|
|
+ */
|
|
|
+ @GetMapping("/exportAgreementPrice/template")
|
|
|
+ @ApiOperationSupport(order = 9)
|
|
|
+ @ApiOperation(value = "导出模板")
|
|
|
+ public void exportAgreementPriceTemplate(HttpServletResponse response) {
|
|
|
+ List<AgreementPriceExcel> list = new ArrayList<>();
|
|
|
+ ExcelUtil.export(response, "导入模板-物流-业务-协议价管理", "协议价", list, AgreementPriceExcel.class);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 导入 物流-业务-协议价管理主表
|
|
|
+ */
|
|
|
+ @PostMapping("/importAgreementPrice")
|
|
|
+ @ApiOperationSupport(order = 13)
|
|
|
+ @ApiOperation(value = "导入 物流-业务-协议价管理主表", notes = "传入excel")
|
|
|
+ public R<List<AgreementPrice>> importAgreementPrice(@RequestParam("file") MultipartFile file) {
|
|
|
+ //导入数据
|
|
|
+ List<AgreementPriceExcel> excelList = ExcelUtil.read(file, AgreementPriceExcel.class);
|
|
|
+ if (CollectionUtils.isEmpty(excelList)) {
|
|
|
+ throw new SecurityException("数据不能为空");
|
|
|
+ }
|
|
|
+ return agreementPriceService.importAgreementPrice(excelList);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|