HomeNoticeController.java 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. package com.ozs.web.controller.home;
  2. import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
  3. import com.baomidou.mybatisplus.core.metadata.IPage;
  4. import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  5. import com.ozs.common.annotation.Log;
  6. import com.ozs.common.constant.ModularConstans;
  7. import com.ozs.common.core.controller.BaseController;
  8. import com.ozs.common.core.domain.AjaxResult;
  9. import com.ozs.common.core.domain.entity.SysUser;
  10. import com.ozs.common.enums.BusinessType;
  11. import com.ozs.common.utils.SecurityUtils;
  12. import com.ozs.common.utils.StringUtils;
  13. import com.ozs.home.domain.HomeNotice;
  14. import com.ozs.home.domain.vo.HomeNoticeVo;
  15. import com.ozs.home.service.HomeNoticeService;
  16. import com.ozs.plan.doman.PlanQuarter;
  17. import com.ozs.plan.doman.PlanYears;
  18. import com.ozs.plan.doman.vo.requestVo.PlanYearsStandardVo;
  19. import com.ozs.plan.service.PlanQuarterService;
  20. import com.ozs.plan.service.PlanYearsService;
  21. import com.ozs.pm.doman.PmDemand;
  22. import io.swagger.annotations.ApiOperation;
  23. import org.springframework.beans.BeanUtils;
  24. import org.springframework.beans.factory.annotation.Autowired;
  25. import org.springframework.security.access.prepost.PreAuthorize;
  26. import org.springframework.util.ObjectUtils;
  27. import org.springframework.web.bind.annotation.PostMapping;
  28. import org.springframework.web.bind.annotation.RequestBody;
  29. import org.springframework.web.bind.annotation.RequestMapping;
  30. import org.springframework.web.bind.annotation.RestController;
  31. import javax.annotation.Resource;
  32. import java.text.ParseException;
  33. import java.text.SimpleDateFormat;
  34. import java.util.Date;
  35. import java.util.List;
  36. import java.util.Map;
  37. /**
  38. * 首页公告控制层
  39. *
  40. * @author buzhanyi
  41. */
  42. @RestController
  43. @RequestMapping("/home/homeNotice")
  44. public class HomeNoticeController extends BaseController {
  45. @Resource
  46. private HomeNoticeService homeNoticeService;
  47. @Autowired
  48. private PlanYearsService planYearsService;
  49. @Autowired
  50. private PlanQuarterService planQuarterService;
  51. @ApiOperation(value = "查询首页公告")
  52. @PostMapping("/selectHomeNotice")
  53. // @PreAuthorize("@ss.hasPermi('home:homeNotice:selecthomeNotice')")
  54. @Log(title = ModularConstans.notice, businessType = BusinessType.QUERY)
  55. public AjaxResult selectHomeNotice(@RequestBody HomeNoticeVo homeNoticeVo) {
  56. LambdaQueryWrapper<HomeNotice> lw = new LambdaQueryWrapper<HomeNotice>();
  57. if (!StringUtils.isBlank(homeNoticeVo.getNoticeName())) {
  58. lw.like(HomeNotice::getNoticeName, "%" + homeNoticeVo.getNoticeName() + "%");
  59. }
  60. if (!StringUtils.isBlank(homeNoticeVo.getAnnouncementClassification())) {
  61. lw.eq(HomeNotice::getAnnouncementClassification, homeNoticeVo.getAnnouncementClassification());
  62. }
  63. if (!StringUtils.isBlank(homeNoticeVo.getHomepageClassification())) {
  64. lw.eq(HomeNotice::getHomepageClassification, homeNoticeVo.getHomepageClassification());
  65. }
  66. if (!ObjectUtils.isEmpty(homeNoticeVo.getBeginTime())) {
  67. lw.ge(HomeNotice::getNoticeTime, homeNoticeVo.getBeginTime());
  68. }
  69. if (!ObjectUtils.isEmpty(homeNoticeVo.getEndTime())) {
  70. lw.le(HomeNotice::getNoticeTime, homeNoticeVo.getEndTime());
  71. }
  72. IPage<HomeNotice> page = homeNoticeService.page(new Page<HomeNotice>(homeNoticeVo.getPageNum(), homeNoticeVo.getPageSize()), lw);
  73. return success(page);
  74. }
  75. @ApiOperation(value = "搜索项目列表")
  76. @PostMapping("/listPlanYears")
  77. public AjaxResult listPlanYears(@RequestBody PlanYearsStandardVo yearsStandardVo) {
  78. if (StringUtils.isNull(yearsStandardVo.getProjectName())) {
  79. return error("查询项目名称不能为空!");
  80. }
  81. LambdaQueryWrapper<PlanYears> lw = new LambdaQueryWrapper<PlanYears>();
  82. if (!StringUtils.isBlank(yearsStandardVo.getProjectName())) {
  83. lw.like(PlanYears::getProjectName, "%" + yearsStandardVo.getProjectName() + "%");
  84. lw.eq(PlanYears::getDelFlay, 0);
  85. if (!SysUser.isAdmin(SecurityUtils.getUserId())) {
  86. lw.eq(PlanYears::getPurchaseDeptId, SecurityUtils.getDeptId());
  87. }
  88. }
  89. List<PlanYears> list = planYearsService.list(lw);
  90. //项目搜索的结果中要包含临时计划
  91. LambdaQueryWrapper<PlanQuarter> ls = new LambdaQueryWrapper<PlanQuarter>();
  92. if (!StringUtils.isBlank(yearsStandardVo.getProjectName())) {
  93. ls.like(PlanQuarter::getProjectName, "%" + yearsStandardVo.getProjectName() + "%");
  94. ls.eq(PlanQuarter::getDelFlay, 0);
  95. ls.eq(PlanQuarter::getPlanType, 1);
  96. if (!SysUser.isAdmin(SecurityUtils.getUserId())) {
  97. ls.eq(PlanQuarter::getPurchaseDeptId, SecurityUtils.getDeptId());
  98. }
  99. }
  100. List<PlanQuarter> lists = planQuarterService.list(ls);
  101. for (PlanYears year : list) {
  102. PlanQuarter quarter = new PlanQuarter();
  103. BeanUtils.copyProperties(year, quarter);
  104. lists.add(quarter);
  105. }
  106. return AjaxResult.success(lists);
  107. }
  108. @ApiOperation(value = "搜索项目--选择项目查看详情")
  109. @PostMapping("/projectDetails")
  110. public AjaxResult projectDetails(@RequestBody PlanYearsStandardVo yearsStandardVo) {
  111. if (StringUtils.isNull(yearsStandardVo.getPlanYearId())) {
  112. return error("项目ID不能为空!");
  113. }
  114. return planYearsService.projectDetails(yearsStandardVo);
  115. }
  116. /**
  117. * 查询不同类型的公告
  118. */
  119. @PreAuthorize("@ss.hasPermi('home:homeNotice:getNoticesByType')")
  120. @Log(title = "查询公告", businessType = BusinessType.QUERY)
  121. @PostMapping("getNoticesByType")
  122. @ApiOperation("查询不同类型的公告")
  123. public AjaxResult getNoticesByType(@RequestBody HomeNoticeVo homeNoticeVo) {
  124. LambdaQueryWrapper<HomeNotice> lw = new LambdaQueryWrapper<>();
  125. if (!ObjectUtils.isEmpty(homeNoticeVo.getNoticeName())) {
  126. lw.like(HomeNotice::getNoticeName, homeNoticeVo.getNoticeName());
  127. }
  128. if (!ObjectUtils.isEmpty(homeNoticeVo.getAnnouncementClassification())) {
  129. lw.eq(HomeNotice::getAnnouncementClassification, homeNoticeVo.getAnnouncementClassification());
  130. }
  131. if (!ObjectUtils.isEmpty(homeNoticeVo.getBeginTime())) {
  132. lw.ge(HomeNotice::getNoticeTime, homeNoticeVo.getBeginTime());
  133. }
  134. if (!ObjectUtils.isEmpty(homeNoticeVo.getEndTime())) {
  135. SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
  136. SimpleDateFormat dateFormatT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");
  137. Date parse = null;
  138. try {
  139. parse = dateFormatT.parse((dateFormat.format(homeNoticeVo.getEndTime()) + " 23:59:59:999"));
  140. } catch (ParseException e) {
  141. e.printStackTrace();
  142. }
  143. lw.le(HomeNotice::getNoticeTime, parse);
  144. }
  145. List<HomeNotice> noticeList = homeNoticeService.list(lw);
  146. return AjaxResult.success(noticeList);
  147. }
  148. }