|
@@ -1,18 +1,30 @@
|
|
|
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.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 org.springframework.beans.factory.annotation.Autowired;
|
|
|
+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;
|
|
@@ -22,7 +34,9 @@ import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* 年度计划信息控制层
|
|
@@ -37,24 +51,166 @@ public class PlanYearsController extends BaseController {
|
|
|
private PlanYearsService planYearsService;
|
|
|
@Autowired
|
|
|
private TokenService tokenService;
|
|
|
+ @Autowired
|
|
|
+ private ISysDeptService iSysDeptService;
|
|
|
+ @Autowired
|
|
|
+ private PlanYearsServiceImpl planYearsServiceImpl;
|
|
|
+
|
|
|
|
|
|
@ApiOperation(value = "查询年度计划")
|
|
|
@PostMapping("/list")
|
|
|
- public AjaxResult list(@RequestBody PlanYearsStandardVo yearsStandardVo) {
|
|
|
- //List<PlanYears> list = planYearsService.selectPlanYearsList(yearsStandardVo);
|
|
|
- Page page = planYearsService.selectPlanYearsList(yearsStandardVo);
|
|
|
- return AjaxResult.success(page);
|
|
|
+ @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())) {
|
|
|
+ lw.le(PlanYears::getPlanDemandSubTime, vo.getEndTime());
|
|
|
+ }
|
|
|
+ lw.eq(PlanYears::getDelFlay, DataIsDelete.DataNOTDelete);
|
|
|
+
|
|
|
+
|
|
|
+ LoginUser loginUser = tokenService.getLoginUser(request);
|
|
|
+ // 添加数据权限
|
|
|
+ List<String> roleKeys = loginUser.getUser().getRoles().stream().map(SysRole::getRoleKey).collect(Collectors.toList());
|
|
|
+ if (roleKeys.contains(Constants.DEMAND_UNIT)) {
|
|
|
+ // 需求单位
|
|
|
+ /*(purchase_dept_id = 当前用户deptID) */
|
|
|
+ lw.eq(PlanYears::getPurchaseDeptId, loginUser.getDeptId());
|
|
|
+ } else if (roleKeys.contains(Constants.PURCHASING_MANAGEMENT)
|
|
|
+ || roleKeys.contains(Constants.PURCHASE_SERVICES)) {
|
|
|
+ // 采购管理部门 或 采购办
|
|
|
+ /* (purchase_dept_id = 当前用户deptID AND is_excess = 0)
|
|
|
+ OR
|
|
|
+ (purchase_dept_id IN (当前用户 子deptId 集合) and AND is_excess = 1)
|
|
|
+ */
|
|
|
+ SysDept sysDept = new SysDept();
|
|
|
+ sysDept.setParentId(loginUser.getDeptId());
|
|
|
+ sysDept.setStatus("0");
|
|
|
+ List<Long> childDeptIds = iSysDeptService.selectDeptList(sysDept)
|
|
|
+ .stream()
|
|
|
+ .map(SysDept::getDeptId)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ if (ObjectUtils.isEmpty(childDeptIds)) {
|
|
|
+ lw.and((wrapper) -> {
|
|
|
+ wrapper.eq(PlanYears::getIsExcess, 0);
|
|
|
+ wrapper.eq(PlanYears::getPurchaseDeptId, loginUser.getDeptId());
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ lw.and((wrapper) -> {
|
|
|
+ wrapper.eq(PlanYears::getIsExcess, 0);
|
|
|
+ wrapper.eq(PlanYears::getPurchaseDeptId, loginUser.getDeptId());
|
|
|
+ })
|
|
|
+ .or((wrapper) -> {
|
|
|
+ wrapper.eq(PlanYears::getIsExcess, 1);
|
|
|
+ wrapper.in(PlanYears::getPurchaseDeptId, childDeptIds);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ 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")
|
|
|
- public AjaxResult examineList(@RequestBody PlanYearsStandardVo yearsStandardVo) {
|
|
|
- Page page = planYearsService.selectPlanYearsExamineList(yearsStandardVo);
|
|
|
- return AjaxResult.success(page);
|
|
|
+ @Log(title = ModularConstans.planYear, businessType = BusinessType.QUERY)
|
|
|
+ public AjaxResult examineList(@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());
|
|
|
+ } else {
|
|
|
+ lw.in(PlanYears::getProjectStatus, "1,3");
|
|
|
+ }
|
|
|
+ if (!ObjectUtils.isEmpty(vo.getBeginTime())) {
|
|
|
+ lw.ge(PlanYears::getPlanDemandSubTime, vo.getBeginTime());
|
|
|
+ }
|
|
|
+ if (!ObjectUtils.isEmpty(vo.getEndTime())) {
|
|
|
+ lw.le(PlanYears::getPlanDemandSubTime, vo.getEndTime());
|
|
|
+ }
|
|
|
+ lw.eq(PlanYears::getDelFlay, DataIsDelete.DataNOTDelete);
|
|
|
+
|
|
|
+
|
|
|
+ LoginUser loginUser = tokenService.getLoginUser(request);
|
|
|
+ // 添加数据权限
|
|
|
+ List<String> roleKeys = loginUser.getUser().getRoles().stream().map(SysRole::getRoleKey).collect(Collectors.toList());
|
|
|
+ if (roleKeys.contains(Constants.DEMAND_UNIT)) {
|
|
|
+ // 需求单位
|
|
|
+ /*(purchase_dept_id = 当前用户deptID) */
|
|
|
+ lw.eq(PlanYears::getPurchaseDeptId, loginUser.getDeptId());
|
|
|
+ } else if (roleKeys.contains(Constants.PURCHASING_MANAGEMENT)
|
|
|
+ || roleKeys.contains(Constants.PURCHASE_SERVICES)) {
|
|
|
+ // 采购管理部门 或 采购办
|
|
|
+ /* (purchase_dept_id = 当前用户deptID AND is_excess = 0)
|
|
|
+ OR
|
|
|
+ (purchase_dept_id IN (当前用户 子deptId 集合) and AND is_excess = 1)
|
|
|
+ */
|
|
|
+ SysDept sysDept = new SysDept();
|
|
|
+ sysDept.setParentId(loginUser.getDeptId());
|
|
|
+ sysDept.setStatus("0");
|
|
|
+ List<Long> childDeptIds = iSysDeptService.selectDeptList(sysDept)
|
|
|
+ .stream()
|
|
|
+ .map(SysDept::getDeptId)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ if (ObjectUtils.isEmpty(childDeptIds)) {
|
|
|
+ lw.and((wrapper) -> {
|
|
|
+ wrapper.eq(PlanYears::getIsExcess, 0);
|
|
|
+ wrapper.eq(PlanYears::getPurchaseDeptId, loginUser.getDeptId());
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ lw.and((wrapper) -> {
|
|
|
+ wrapper.eq(PlanYears::getIsExcess, 0);
|
|
|
+ wrapper.eq(PlanYears::getPurchaseDeptId, loginUser.getDeptId());
|
|
|
+ })
|
|
|
+ .or((wrapper) -> {
|
|
|
+ wrapper.eq(PlanYears::getIsExcess, 1);
|
|
|
+ wrapper.in(PlanYears::getPurchaseDeptId, childDeptIds);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ 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("/exportPlan")
|
|
|
+ @Log(title = ModularConstans.planYear, businessType = BusinessType.EXPORT)
|
|
|
public void exportPlan(HttpServletResponse response, @RequestBody PlanYearsStandardVo yearsStandardVo) throws Exception {
|
|
|
List<PlanYearsResponseVo> list = planYearsService.selectPlanYearsListEXP(yearsStandardVo);
|
|
|
ExcelUtil<PlanYearsResponseVo> util = new ExcelUtil<>(PlanYearsResponseVo.class);
|
|
@@ -63,6 +219,7 @@ public class PlanYearsController extends BaseController {
|
|
|
|
|
|
@ApiOperation(value = "导出年度计划数据(审核单位)")
|
|
|
@PostMapping("/exportPlanExamine")
|
|
|
+ @Log(title = ModularConstans.planYear, businessType = BusinessType.EXPORT)
|
|
|
public void exportPlanExamine(HttpServletResponse response, @RequestBody PlanYearsStandardVo yearsStandardVo) throws Exception {
|
|
|
List<PlanYearsResponseVo> list = planYearsService.selectPlanYearsExamineListEXP(yearsStandardVo);
|
|
|
ExcelUtil<PlanYearsResponseVo> util = new ExcelUtil<>(PlanYearsResponseVo.class);
|
|
@@ -71,6 +228,7 @@ public class PlanYearsController extends BaseController {
|
|
|
|
|
|
@ApiOperation(value = "创建年度计划")
|
|
|
@PostMapping("/add")
|
|
|
+ @Log(title = ModularConstans.planYear, businessType = BusinessType.INSERT)
|
|
|
public AjaxResult add(@RequestBody PlanYearsStandardVo yearsStandardVo, HttpServletRequest request) {
|
|
|
//获取采购单位-
|
|
|
LoginUser loginUser = tokenService.getLoginUser(request);
|
|
@@ -81,6 +239,7 @@ public class PlanYearsController extends BaseController {
|
|
|
|
|
|
@ApiOperation(value = "修改年度计划")
|
|
|
@PostMapping("/update")
|
|
|
+ @Log(title = ModularConstans.planYear, businessType = BusinessType.UPDATE)
|
|
|
public AjaxResult update(@RequestBody PlanYearsStandardVo yearsStandardVo, HttpServletRequest request) {
|
|
|
LoginUser loginUser = tokenService.getLoginUser(request);
|
|
|
yearsStandardVo.setUpdated(String.valueOf(loginUser.getUserId()));
|
|
@@ -89,24 +248,28 @@ public class PlanYearsController extends BaseController {
|
|
|
|
|
|
@ApiOperation(value = "提交年度计划")
|
|
|
@PostMapping("/commit")
|
|
|
+ @Log(title = ModularConstans.planYear, businessType = BusinessType.UPDATE)
|
|
|
public AjaxResult commit(@RequestBody PlanYearsStandardVo yearsStandardVo) {
|
|
|
return planYearsService.commit(yearsStandardVo);
|
|
|
}
|
|
|
|
|
|
@ApiOperation(value = "删除年度计划")
|
|
|
@PostMapping("/delete")
|
|
|
+ @Log(title = ModularConstans.planYear, businessType = BusinessType.DELETE)
|
|
|
public AjaxResult delete(@RequestBody PlanYearsStandardVo yearsStandardVo) {
|
|
|
return planYearsService.deletePlanYearsById(yearsStandardVo.getPlanYearId());
|
|
|
}
|
|
|
|
|
|
@ApiOperation(value = "根据id获取年度计划信息")
|
|
|
@PostMapping("/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)
|
|
|
public AjaxResult reviewTo(@RequestBody PlanYearsStandardVo yearsStandardVo, HttpServletRequest request) {
|
|
|
LoginUser loginUser = tokenService.getLoginUser(request);
|
|
|
yearsStandardVo.setUpdated(String.valueOf(loginUser.getUserId()));
|
|
@@ -115,6 +278,7 @@ public class PlanYearsController extends BaseController {
|
|
|
|
|
|
@ApiOperation(value = "审核年度计划退回")
|
|
|
@PostMapping("/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()));
|
|
@@ -123,18 +287,21 @@ public class PlanYearsController extends BaseController {
|
|
|
|
|
|
@ApiOperation(value = "申请修改年度计划")
|
|
|
@PostMapping("/appUpdate")
|
|
|
+ @Log(title = ModularConstans.planYear, businessType = BusinessType.UPDATE)
|
|
|
public AjaxResult appUpdate(@RequestBody PlanYearsStandardVo yearsStandardVo) {
|
|
|
return planYearsService.appUpdate(yearsStandardVo);
|
|
|
}
|
|
|
|
|
|
@ApiOperation(value = "发函催告")
|
|
|
@PostMapping("/sendLetter")
|
|
|
+ @Log(title = ModularConstans.planYear, businessType = BusinessType.UPDATE)
|
|
|
public AjaxResult sendLetter(@RequestBody PlanYearsStandardVo yearsStandardVo) {
|
|
|
return planYearsService.sendLetter(yearsStandardVo);
|
|
|
}
|
|
|
|
|
|
@ApiOperation(value = "上传计划关联文件后保存文件信息")
|
|
|
@PostMapping("/upLoadPlanFile")
|
|
|
+ @Log(title = ModularConstans.planYear, businessType = BusinessType.OTHER)
|
|
|
public AjaxResult upLoadPlanFile(@RequestBody PlanYearsStandardVo yearsStandardVo) {
|
|
|
return planYearsService.upLoadPlanFile(yearsStandardVo);
|
|
|
}
|
|
@@ -147,6 +314,7 @@ public class PlanYearsController extends BaseController {
|
|
|
|
|
|
@ApiOperation(value = "导入年度计划数据")
|
|
|
@PostMapping("/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());
|
|
@@ -158,7 +326,8 @@ public class PlanYearsController extends BaseController {
|
|
|
|
|
|
@ApiOperation(value = "系统首页计划管理")
|
|
|
@GetMapping("/planYearsTotal")
|
|
|
- public AjaxResult planYearsTotal(){
|
|
|
- return success(planYearsService.count());
|
|
|
+ @Log(title = ModularConstans.planYear, businessType = BusinessType.QUERY)
|
|
|
+ public AjaxResult planYearsTotal() {
|
|
|
+ return success(planYearsService.count());
|
|
|
}
|
|
|
}
|