123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284 |
- package com.ozs.web.controller.plan;
- import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
- import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
- import com.ozs.common.annotation.Log;
- import com.ozs.common.constant.Constants;
- import com.ozs.common.constant.ModularConstans;
- import com.ozs.common.core.controller.BaseController;
- import com.ozs.common.core.domain.AjaxResult;
- import com.ozs.common.core.domain.entity.SysDept;
- import com.ozs.common.core.domain.entity.SysRole;
- import com.ozs.common.core.domain.model.LoginUser;
- import com.ozs.common.enums.BusinessType;
- import com.ozs.common.enums.DataIsDelete;
- import com.ozs.common.utils.PageUtils;
- import com.ozs.common.utils.file.FileUtils;
- import com.ozs.common.utils.poi.ExcelUtil;
- import com.ozs.framework.web.service.TokenService;
- import com.ozs.plan.doman.PlanYears;
- import com.ozs.plan.doman.vo.requestVo.PlanYearsStandardVo;
- import com.ozs.plan.doman.vo.responseVo.PlanYearsResponseVo;
- import com.ozs.plan.service.PlanYearsService;
- import com.ozs.plan.service.impl.PlanYearsServiceImpl;
- import com.ozs.system.service.ISysDeptService;
- import io.swagger.annotations.Api;
- import io.swagger.annotations.ApiOperation;
- import lombok.extern.slf4j.Slf4j;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.http.MediaType;
- import org.springframework.security.access.prepost.PreAuthorize;
- import org.springframework.util.ObjectUtils;
- 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 org.springframework.web.multipart.MultipartFile;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import java.io.InputStream;
- import java.text.SimpleDateFormat;
- import java.util.ArrayList;
- import java.util.Date;
- import java.util.List;
- import java.util.stream.Collectors;
- /**
- * 年度计划信息控制层
- *
- * @author buzhanyi
- */
- @Api(tags = "年度计划")
- @Slf4j
- @RestController
- @RequestMapping("/plan/planYears")
- public class PlanYearsController extends BaseController {
- @Autowired
- private PlanYearsService planYearsService;
- @Autowired
- private TokenService tokenService;
- @Autowired
- private ISysDeptService iSysDeptService;
- @Autowired
- private PlanYearsServiceImpl planYearsServiceImpl;
- @ApiOperation(value = "查询年度计划")
- @PostMapping("/list")
- @PreAuthorize("@ss.hasPermi('plan:planYears:list')")
- @Log(title = ModularConstans.planYear, businessType = BusinessType.QUERY)
- public AjaxResult list(@RequestBody PlanYearsStandardVo vo, HttpServletRequest request) {
- List<PlanYearsResponseVo> planYearsList = new ArrayList<>();
- try {
- LambdaQueryWrapper<PlanYears> lw = new LambdaQueryWrapper<PlanYears>();
- if (!ObjectUtils.isEmpty(vo.getProjectName())) {
- lw.like(PlanYears::getProjectName, vo.getProjectName());
- }
- if (!ObjectUtils.isEmpty(vo.getPurchaseServices())) {
- lw.eq(PlanYears::getPurchaseServices, vo.getPurchaseServices());
- }
- if (!ObjectUtils.isEmpty(vo.getIsExcess())) {
- lw.eq(PlanYears::getIsExcess, vo.getIsExcess());
- }
- if (!ObjectUtils.isEmpty(vo.getProjectStatus())) {
- lw.eq(PlanYears::getProjectStatus, vo.getProjectStatus());
- }
- if (!ObjectUtils.isEmpty(vo.getBeginTime())) {
- lw.ge(PlanYears::getPlanDemandSubTime, vo.getBeginTime());
- }
- if (!ObjectUtils.isEmpty(vo.getEndTime())) {
- SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
- SimpleDateFormat dateFormatT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");
- Date parse = dateFormatT.parse(dateFormat.format(vo.getEndTime()) + " 23:59:59:999");
- lw.le(PlanYears::getPlanDemandSubTime, parse);
- }
- lw.eq(PlanYears::getDelFlay, DataIsDelete.DataNOTDelete.getCode());
- lw.orderBy(true, false, PlanYears::getCreateTime);
- List<PlanYears> planYears = planYearsService.list(lw);
- planYearsList = planYearsServiceImpl.changeTo(planYears);
- } catch (Exception e) {
- e.printStackTrace();
- }
- Page pages = PageUtils.getPages(vo.getPageNum().intValue(), vo.getPageSize().intValue(), planYearsList);
- return AjaxResult.success(pages);
- }
- @ApiOperation(value = "审核单位查询年度计划")
- @PostMapping("/examineList")
- @PreAuthorize("@ss.hasPermi('plan:planYears:examineList')")
- @Log(title = ModularConstans.planYear, businessType = BusinessType.QUERY)
- public AjaxResult examineList(@RequestBody PlanYearsStandardVo vo, HttpServletRequest request) {
- List<PlanYearsResponseVo> planYearsList = new ArrayList<>();
- try {
- LoginUser loginUser = tokenService.getLoginUser(request);
- vo.setPurchaseDeptId(String.valueOf(loginUser.getDeptId()));
- vo.setCreated(String.valueOf(loginUser.getUserId()));
- List<PlanYears> planYears = planYearsService.queryPage(vo);
- if (!ObjectUtils.isEmpty(planYears) && !ObjectUtils.isEmpty(planYears.size())) {
- planYearsList = planYearsServiceImpl.changeTo(planYears);
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- Page pages = PageUtils.getPages(vo.getPageNum().intValue(), vo.getPageSize().intValue(), planYearsList);
- return AjaxResult.success(pages);
- }
- @ApiOperation(value = "导出年度计划数据")
- @PostMapping("/exportPlan")
- @PreAuthorize("@ss.hasPermi('plan:planYears:exportPlan')")
- @Log(title = ModularConstans.planYear, businessType = BusinessType.EXPORT)
- public void exportPlan(HttpServletResponse response, @RequestBody PlanYearsStandardVo yearsStandardVo, HttpServletRequest request) throws Exception {
- LoginUser loginUser = tokenService.getLoginUser(request);
- List<PlanYearsResponseVo> list = planYearsService.selectPlanYearsListEXP(yearsStandardVo, loginUser);
- ExcelUtil<PlanYearsResponseVo> util = new ExcelUtil<>(PlanYearsResponseVo.class);
- util.exportExcel(response, list, "年度计划数据");
- }
- @ApiOperation(value = "导出年度计划数据(审核单位)")
- @PreAuthorize("@ss.hasPermi('plan:planYears:exportPlanExamine')")
- @PostMapping("/exportPlanExamine")
- @Log(title = ModularConstans.planYear, businessType = BusinessType.EXPORT)
- public void exportPlanExamine(HttpServletResponse response, @RequestBody PlanYearsStandardVo yearsStandardVo, HttpServletRequest request) throws Exception {
- LoginUser loginUser = tokenService.getLoginUser(request);
- List<PlanYearsResponseVo> list = planYearsService.selectPlanYearsExamineListEXP(yearsStandardVo, loginUser);
- ExcelUtil<PlanYearsResponseVo> util = new ExcelUtil<>(PlanYearsResponseVo.class);
- util.exportExcel(response, list, "年度计划数据(审核单位)");
- }
- @ApiOperation(value = "创建年度计划")
- @PostMapping("/add")
- @PreAuthorize("@ss.hasPermi('plan:planYears:add')")
- @Log(title = ModularConstans.planYear, businessType = BusinessType.INSERT)
- public AjaxResult add(@RequestBody PlanYearsStandardVo yearsStandardVo, HttpServletRequest request) {
- //获取采购单位-
- LoginUser loginUser = tokenService.getLoginUser(request);
- yearsStandardVo.setPurchaseDeptId(String.valueOf(loginUser.getDeptId()));
- yearsStandardVo.setCreated(String.valueOf(loginUser.getUserId()));
- return planYearsService.insertPlanYears(yearsStandardVo);
- }
- @ApiOperation(value = "修改年度计划")
- @PostMapping("/update")
- @PreAuthorize("@ss.hasPermi('plan:planYears:update')")
- @Log(title = ModularConstans.planYear, businessType = BusinessType.UPDATE)
- public AjaxResult update(@RequestBody PlanYearsStandardVo yearsStandardVo, HttpServletRequest request) {
- LoginUser loginUser = tokenService.getLoginUser(request);
- yearsStandardVo.setPurchaseDeptId(String.valueOf(loginUser.getDeptId()));
- yearsStandardVo.setUpdated(String.valueOf(loginUser.getUserId()));
- return planYearsService.update(yearsStandardVo);
- }
- @ApiOperation(value = "提交年度计划")
- @PostMapping("/commit")
- @PreAuthorize("@ss.hasPermi('plan:planYears:commit')")
- @Log(title = ModularConstans.planYear, businessType = BusinessType.UPDATE)
- public AjaxResult commit(@RequestBody PlanYearsStandardVo yearsStandardVo) {
- return planYearsService.commit(yearsStandardVo);
- }
- @ApiOperation(value = "删除年度计划")
- @PostMapping("/delete")
- @PreAuthorize("@ss.hasPermi('plan:planYears:delete')")
- @Log(title = ModularConstans.planYear, businessType = BusinessType.DELETE)
- public AjaxResult delete(@RequestBody PlanYearsStandardVo yearsStandardVo) {
- return planYearsService.deletePlanYearsById(yearsStandardVo.getPlanYearId());
- }
- @ApiOperation(value = "根据id获取年度计划信息")
- @PostMapping("/view")
- // @PreAuthorize("@ss.hasPermi('plan:planYears:view')") 首页调用的接口不需要权限
- @Log(title = ModularConstans.planYear, businessType = BusinessType.QUERY)
- public AjaxResult view(@RequestBody PlanYearsStandardVo yearsStandardVo) {
- return planYearsService.view(yearsStandardVo);
- }
- @ApiOperation(value = "审核年度计划通过")
- @PostMapping("/reviewTo")
- @Log(title = ModularConstans.planYear, businessType = BusinessType.UPDATE)
- @PreAuthorize("@ss.hasPermi('plan:planYears:reviewTo')")
- public AjaxResult reviewTo(@RequestBody PlanYearsStandardVo yearsStandardVo, HttpServletRequest request) {
- LoginUser loginUser = tokenService.getLoginUser(request);
- yearsStandardVo.setUpdated(String.valueOf(loginUser.getUserId()));
- return planYearsService.reviewTo(yearsStandardVo);
- }
- @ApiOperation(value = "审核年度计划退回")
- @PostMapping("/reviewReturn")
- @PreAuthorize("@ss.hasPermi('plan:planYears:reviewReturn')")
- @Log(title = ModularConstans.planYear, businessType = BusinessType.UPDATE)
- public AjaxResult reviewReturn(@RequestBody PlanYearsStandardVo yearsStandardVo, HttpServletRequest request) {
- LoginUser loginUser = tokenService.getLoginUser(request);
- yearsStandardVo.setUpdated(String.valueOf(loginUser.getUserId()));
- return planYearsService.reviewReturn(yearsStandardVo);
- }
- @ApiOperation(value = "申请修改年度计划")
- @PostMapping("/appUpdate")
- @PreAuthorize("@ss.hasPermi('plan:planYears:appUpdate')")
- @Log(title = ModularConstans.planYear, businessType = BusinessType.UPDATE)
- public AjaxResult appUpdate(@RequestBody PlanYearsStandardVo yearsStandardVo) {
- return planYearsService.appUpdate(yearsStandardVo);
- }
- @ApiOperation(value = "发函催告")
- @PostMapping("/sendLetter")
- @PreAuthorize("@ss.hasPermi('plan:planYears:sendLetter')")
- @Log(title = ModularConstans.planYear, businessType = BusinessType.UPDATE)
- public AjaxResult sendLetter(@RequestBody PlanYearsStandardVo yearsStandardVo) {
- return planYearsService.sendLetter(yearsStandardVo);
- }
- @ApiOperation(value = "上传计划关联文件后保存文件信息")
- @PostMapping("/upLoadPlanFile")
- @PreAuthorize("@ss.hasPermi('plan:planYears:upLoadPlanFile')")
- @Log(title = ModularConstans.planYear, businessType = BusinessType.OTHER)
- public AjaxResult upLoadPlanFile(@RequestBody PlanYearsStandardVo yearsStandardVo) {
- return planYearsService.upLoadPlanFile(yearsStandardVo);
- }
- //
- //@ApiOperation(value = "下载计划关联文件")
- //@PostMapping("/downLoadPlanFile")
- //public AjaxResult downLoadPlanFile(@RequestBody PlanYearsStandardVo yearsStandardVo) {
- // return planYearsService.downLoadPlanFile(yearsStandardVo);
- @ApiOperation(value = "导入年度计划数据")
- @PostMapping("/importData")
- @PreAuthorize("@ss.hasPermi('plan:planYears:importData')")
- @Log(title = ModularConstans.planYear, businessType = BusinessType.INSERT)
- public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception {
- ExcelUtil<PlanYearsStandardVo> util = new ExcelUtil<>(PlanYearsStandardVo.class);
- List<PlanYearsStandardVo> planYears = util.importExcel(file.getInputStream());
- //获取采购单位-
- LoginUser loginUser = getLoginUser();
- String message = planYearsService.importPlanYears(planYears, updateSupport, loginUser);
- return success(message);
- }
- @ApiOperation(value = "系统首页计划管理")
- @GetMapping("/planYearsTotal")
- @PreAuthorize("@ss.hasPermi('plan:planYears:planYearsTotal')")
- @Log(title = ModularConstans.planYear, businessType = BusinessType.QUERY)
- public AjaxResult planYearsTotal() {
- return success(planYearsService.count());
- }
- @ApiOperation("模板下载")
- @GetMapping("/downloaExcel")
- public void downloadZip(HttpServletResponse response) {
- try {
- InputStream resourceAsStream = this.getClass().getResourceAsStream("/template/planYears.xlsx");
- response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
- FileUtils.setAttachmentResponseHeader(response, "年度计划导入模板.xlsx");
- FileUtils.writeBytesByInput(resourceAsStream, response.getOutputStream());
- } catch (Exception e) {
- log.error("下载文件失败", e);
- }
- }
- }
|