|
@@ -1,5 +1,8 @@
|
|
package com.ozs.web.controller.plan;
|
|
package com.ozs.web.controller.plan;
|
|
|
|
|
|
|
|
+import com.alibaba.excel.EasyExcel;
|
|
|
|
+import com.alibaba.excel.ExcelWriter;
|
|
|
|
+import com.alibaba.excel.write.metadata.WriteSheet;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.ozs.common.annotation.Log;
|
|
import com.ozs.common.annotation.Log;
|
|
import com.ozs.common.constant.ModularConstans;
|
|
import com.ozs.common.constant.ModularConstans;
|
|
@@ -9,12 +12,14 @@ import com.ozs.common.core.domain.model.LoginUser;
|
|
import com.ozs.common.enums.BusinessType;
|
|
import com.ozs.common.enums.BusinessType;
|
|
import com.ozs.common.enums.SysFileRefEnum;
|
|
import com.ozs.common.enums.SysFileRefEnum;
|
|
import com.ozs.common.exception.ServiceException;
|
|
import com.ozs.common.exception.ServiceException;
|
|
|
|
+import com.ozs.common.exception.base.BaseException;
|
|
import com.ozs.common.utils.PageUtils;
|
|
import com.ozs.common.utils.PageUtils;
|
|
import com.ozs.common.utils.StringUtils;
|
|
import com.ozs.common.utils.StringUtils;
|
|
import com.ozs.common.utils.file.FileUtils;
|
|
import com.ozs.common.utils.file.FileUtils;
|
|
import com.ozs.common.utils.poi.ExcelUtil;
|
|
import com.ozs.common.utils.poi.ExcelUtil;
|
|
import com.ozs.framework.web.service.TokenService;
|
|
import com.ozs.framework.web.service.TokenService;
|
|
import com.ozs.plan.doman.ProvisionalPlan;
|
|
import com.ozs.plan.doman.ProvisionalPlan;
|
|
|
|
+import com.ozs.plan.doman.vo.requestVo.PlanYearsStandardVo;
|
|
import com.ozs.plan.doman.vo.requestVo.ProvisionalPlanVo;
|
|
import com.ozs.plan.doman.vo.requestVo.ProvisionalPlanVo;
|
|
import com.ozs.plan.doman.vo.responseVo.ProvisionalPlanResVo;
|
|
import com.ozs.plan.doman.vo.responseVo.ProvisionalPlanResVo;
|
|
import com.ozs.plan.service.ProvisionalPlanService;
|
|
import com.ozs.plan.service.ProvisionalPlanService;
|
|
@@ -38,6 +43,9 @@ import org.springframework.web.multipart.MultipartFile;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import java.io.InputStream;
|
|
import java.io.InputStream;
|
|
|
|
+import java.io.OutputStream;
|
|
|
|
+import java.math.BigDecimal;
|
|
|
|
+import java.net.URLEncoder;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
@@ -260,17 +268,45 @@ public class ProvisionalPlanController extends BaseController {
|
|
return provisionalPlanService.auditNoPass(provisionalPlanVo);
|
|
return provisionalPlanService.auditNoPass(provisionalPlanVo);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @ApiOperation(value = "填写采购服务站")
|
|
|
|
+ @PostMapping("/adPurchaseServices")
|
|
|
|
+ //@PreAuthorize("@ss.hasPermi('plan:planYears:adPurchaseServices')")
|
|
|
|
+ @Log(title = ModularConstans.provisionalPlan, businessType = BusinessType.UPDATE)
|
|
|
|
+ public AjaxResult adPurchaseServices(@RequestBody ProvisionalPlanVo provisionalPlanVo) {
|
|
|
|
+ return provisionalPlanService.adPurchaseServices(provisionalPlanVo);
|
|
|
|
+ }
|
|
|
|
|
|
@ApiOperation("模板下载")
|
|
@ApiOperation("模板下载")
|
|
@GetMapping("/downloaExcel")
|
|
@GetMapping("/downloaExcel")
|
|
public void downloadZip(HttpServletResponse response) {
|
|
public void downloadZip(HttpServletResponse response) {
|
|
|
|
+ List<ProvisionalPlanResVo> list = new ArrayList<ProvisionalPlanResVo>();
|
|
|
|
+ list.add(new ProvisionalPlanResVo(1L, "单位1", "环太平洋项目", "物资服务类",
|
|
|
|
+ "徒步环太平洋", new BigDecimal(12.23), "单位1,单位2", "科目一",
|
|
|
|
+ "2023-02", "2023-03", "2023-04",
|
|
|
|
+ "重点采购项目,重大规划任务项目", ""));
|
|
|
|
+ list.add(new ProvisionalPlanResVo(2L, "单位2", "环北冰洋项目", "工程类",
|
|
|
|
+ "徒步环北冰洋", new BigDecimal(15.88), "单位1", "科目二",
|
|
|
|
+ "2023-01", "2023-05", "2023-08",
|
|
|
|
+ "重点采购项目", ""));
|
|
|
|
+ InputStream resourceAsStream = this.getClass().getResourceAsStream("/template/provisional_plan.xlsx");
|
|
|
|
+ OutputStream outputStream = null;
|
|
try {
|
|
try {
|
|
- InputStream resourceAsStream = this.getClass().getResourceAsStream("/template/provisionalPlan.xlsx");
|
|
|
|
- response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
|
|
|
|
- FileUtils.setAttachmentResponseHeader(response, "临时计划导入模板.xlsx");
|
|
|
|
- FileUtils.writeBytesByInput(resourceAsStream, response.getOutputStream());
|
|
|
|
|
|
+ response.setContentType("application/vnd.ms-excel");
|
|
|
|
+ response.setCharacterEncoding("utf-8");
|
|
|
|
+ // 这里URLEncoder.encode可以防止中文乱码 当然和easyexcel没有关系
|
|
|
|
+ String fileName = URLEncoder.encode("年度计划(模板)", "UTF-8").replaceAll("\\+", "%20");
|
|
|
|
+ response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx");
|
|
|
|
+ outputStream = response.getOutputStream();
|
|
|
|
+ ExcelWriter excelWriter = EasyExcel.write(outputStream)
|
|
|
|
+ .withTemplate(resourceAsStream).autoCloseStream(true).build();
|
|
|
|
+ WriteSheet writeSheet = EasyExcel.writerSheet().build();
|
|
|
|
+ excelWriter.fill(list, writeSheet);
|
|
|
|
+ excelWriter.finish();
|
|
|
|
+ outputStream.flush();
|
|
|
|
+ outputStream.close();
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
- log.error("下载文件失败", e);
|
|
|
|
|
|
+ log.error(e.getMessage());
|
|
|
|
+ throw new BaseException("下载文件失败");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|