123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324 |
- 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.PlanQuarter;
- import com.ozs.plan.doman.vo.requestVo.PlanQuarterStandardVo;
- import com.ozs.plan.doman.vo.responseVo.PlanQuarterResponseVo;
- import com.ozs.plan.service.PlanQuarterService;
- import com.ozs.plan.service.impl.PlanQuarterServiceImpl;
- 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.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.util.ArrayList;
- import java.util.List;
- import java.util.stream.Collectors;
- /**
- * 季度计划信息控制层
- *
- * @author buzhanyi
- */
- @Api(tags = "季度计划")
- @RestController
- @RequestMapping("/plan/quarter")
- public class PlanQuarterController extends BaseController {
- @Autowired
- private PlanQuarterService quarterService;
- @Autowired
- private PlanQuarterServiceImpl quarterServiceImpl;
- @Autowired
- private TokenService tokenService;
- @Autowired
- private ISysDeptService iSysDeptService;
- @ApiOperation(value = "查询季度计划")
- @PostMapping("/list")
- @Log(title = ModularConstans.planQuarter, businessType = BusinessType.QUERY)
- public AjaxResult list(@RequestBody PlanQuarterStandardVo vo, HttpServletRequest request) {
- List<PlanQuarterResponseVo> planQuarterList = new ArrayList<>();
- try {
- LambdaQueryWrapper<PlanQuarter> lw = new LambdaQueryWrapper<>();
- if (!ObjectUtils.isEmpty(vo.getProjectName())) {
- lw.like(PlanQuarter::getProjectName, vo.getProjectName());
- }
- if (!ObjectUtils.isEmpty(vo.getPurchaseServices())) {
- lw.eq(PlanQuarter::getPurchaseServices, vo.getPurchaseServices());
- }
- if (!ObjectUtils.isEmpty(vo.getIsExcess())) {
- lw.eq(PlanQuarter::getIsExcess, vo.getIsExcess());
- }
- if (!ObjectUtils.isEmpty(vo.getProjectStatus())) {
- lw.eq(PlanQuarter::getProjectStatus, vo.getProjectStatus());
- } else {
- lw.in(PlanQuarter::getProjectStatus, "1,3");
- }
- if (!ObjectUtils.isEmpty(vo.getBeginTime())) {
- lw.ge(PlanQuarter::getPlanDemandSubTime, vo.getBeginTime());
- }
- if (!ObjectUtils.isEmpty(vo.getEndTime())) {
- lw.le(PlanQuarter::getPlanDemandSubTime, vo.getEndTime());
- }
- lw.eq(PlanQuarter::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(PlanQuarter::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(PlanQuarter::getIsExcess, 0);
- wrapper.eq(PlanQuarter::getPurchaseDeptId, loginUser.getDeptId());
- });
- } else {
- lw.and((wrapper) -> {
- wrapper.eq(PlanQuarter::getIsExcess, 0);
- wrapper.eq(PlanQuarter::getPurchaseDeptId, loginUser.getDeptId());
- })
- .or((wrapper) -> {
- wrapper.eq(PlanQuarter::getIsExcess, 1);
- wrapper.in(PlanQuarter::getPurchaseDeptId, childDeptIds);
- });
- }
- }
- List<PlanQuarter> list = quarterService.list(lw);
- planQuarterList = quarterServiceImpl.changeTo(list);
- } catch (Exception e) {
- e.printStackTrace();
- }
- Page pages = PageUtils.getPages(vo.getPageNum().intValue(), vo.getPageSize().intValue(), planQuarterList);
- return AjaxResult.success(pages);
- }
- @ApiOperation(value = "审核单位查询季度计划")
- @PostMapping("/examineList")
- @Log(title = ModularConstans.planQuarter, businessType = BusinessType.QUERY)
- public AjaxResult examineList(@RequestBody PlanQuarterStandardVo vo, HttpServletRequest request) {
- List<PlanQuarterResponseVo> planQuarterList = new ArrayList<>();
- try {
- LambdaQueryWrapper<PlanQuarter> lw = new LambdaQueryWrapper<>();
- if (!ObjectUtils.isEmpty(vo.getProjectName())) {
- lw.like(PlanQuarter::getProjectName, vo.getProjectName());
- }
- if (!ObjectUtils.isEmpty(vo.getPurchaseServices())) {
- lw.eq(PlanQuarter::getPurchaseServices, vo.getPurchaseServices());
- }
- if (!ObjectUtils.isEmpty(vo.getIsExcess())) {
- lw.eq(PlanQuarter::getIsExcess, vo.getIsExcess());
- }
- if (!ObjectUtils.isEmpty(vo.getProjectStatus())) {
- lw.eq(PlanQuarter::getProjectStatus, vo.getProjectStatus());
- }
- if (!ObjectUtils.isEmpty(vo.getBeginTime())) {
- lw.ge(PlanQuarter::getPlanDemandSubTime, vo.getBeginTime());
- }
- if (!ObjectUtils.isEmpty(vo.getEndTime())) {
- lw.le(PlanQuarter::getPlanDemandSubTime, vo.getEndTime());
- }
- lw.eq(PlanQuarter::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(PlanQuarter::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(PlanQuarter::getIsExcess, 0);
- wrapper.eq(PlanQuarter::getPurchaseDeptId, loginUser.getDeptId());
- });
- } else {
- lw.and((wrapper) -> {
- wrapper.eq(PlanQuarter::getIsExcess, 0);
- wrapper.eq(PlanQuarter::getPurchaseDeptId, loginUser.getDeptId());
- })
- .or((wrapper) -> {
- wrapper.eq(PlanQuarter::getIsExcess, 1);
- wrapper.in(PlanQuarter::getPurchaseDeptId, childDeptIds);
- });
- }
- }
- List<PlanQuarter> list = quarterService.list(lw);
- planQuarterList = quarterServiceImpl.changeTo(list);
- } catch (Exception e) {
- e.printStackTrace();
- }
- Page pages = PageUtils.getPages(vo.getPageNum().intValue(), vo.getPageSize().intValue(), planQuarterList);
- return AjaxResult.success(pages);
- }
- @ApiOperation(value = "导出季度计划数据")
- @Log(title = ModularConstans.planQuarter, businessType = BusinessType.EXPORT)
- @PostMapping("/exportPlan")
- public void exportPlan(HttpServletResponse response, @RequestBody PlanQuarterStandardVo quarterStandardVo) throws Exception {
- List<PlanQuarterResponseVo> list = quarterService.selectPlanQuarterListEXP(quarterStandardVo);
- ExcelUtil<PlanQuarterResponseVo> util = new ExcelUtil<>(PlanQuarterResponseVo.class);
- util.exportExcel(response, list, "季度计划数据");
- }
- @ApiOperation(value = "导出季度计划数据(审核单位)")
- @PostMapping("/exportPlanExamine")
- @Log(title = ModularConstans.planQuarter, businessType = BusinessType.EXPORT)
- public void exportPlanExamine(HttpServletResponse response, @RequestBody PlanQuarterStandardVo quarterStandardVo) throws Exception {
- List<PlanQuarterResponseVo> list = quarterService.selectPlanQuarterExamineListEXP(quarterStandardVo);
- ExcelUtil<PlanQuarterResponseVo> util = new ExcelUtil<>(PlanQuarterResponseVo.class);
- util.exportExcel(response, list, "季度计划数据(审核单位)");
- }
- @ApiOperation(value = "创建季度计划")
- @PostMapping("/add")
- @Log(title = ModularConstans.planQuarter, businessType = BusinessType.INSERT)
- public AjaxResult add(@RequestBody PlanQuarterStandardVo quarterStandardVo, HttpServletRequest request) {
- //获取采购单位-
- LoginUser loginUser = tokenService.getLoginUser(request);
- quarterStandardVo.setPurchaseDeptId(String.valueOf(loginUser.getDeptId()));
- quarterStandardVo.setCreated(String.valueOf(loginUser.getUserId()));
- return quarterService.insertPlanQuarter(quarterStandardVo);
- }
- @ApiOperation(value = "修改季度计划")
- @PostMapping("/update")
- @Log(title = ModularConstans.planQuarter, businessType = BusinessType.UPDATE)
- public AjaxResult update(@RequestBody PlanQuarterStandardVo quarterStandardVo, HttpServletRequest request) {
- LoginUser loginUser = tokenService.getLoginUser(request);
- quarterStandardVo.setUpdated(String.valueOf(loginUser.getUserId()));
- return quarterService.update(quarterStandardVo);
- }
- @ApiOperation(value = "提交季度计划")
- @PostMapping("/commit")
- @Log(title = ModularConstans.planQuarter, businessType = BusinessType.UPDATE)
- public AjaxResult commit(@RequestBody PlanQuarterStandardVo quarterStandardVo) {
- return quarterService.commit(quarterStandardVo);
- }
- @ApiOperation(value = "删除季度计划")
- @PostMapping("/delete")
- @Log(title = ModularConstans.planQuarter, businessType = BusinessType.DELETE)
- public AjaxResult delete(@RequestBody PlanQuarterStandardVo quarterStandardVo) {
- return quarterService.deletePlanQuarterById(quarterStandardVo.getPlanPracticalId());
- }
- @ApiOperation(value = "根据id获取季度计划信息")
- @PostMapping("/view")
- @Log(title = ModularConstans.planQuarter, businessType = BusinessType.QUERY)
- public AjaxResult view(@RequestBody PlanQuarterStandardVo quarterStandardVo) {
- return quarterService.view(quarterStandardVo);
- }
- @ApiOperation(value = "审核季度计划通过")
- @PostMapping("/reviewTo")
- @Log(title = ModularConstans.planQuarter, businessType = BusinessType.UPDATE)
- public AjaxResult reviewTo(@RequestBody PlanQuarterStandardVo quarterStandardVo, HttpServletRequest request) {
- LoginUser loginUser = tokenService.getLoginUser(request);
- quarterStandardVo.setUpdated(String.valueOf(loginUser.getUserId()));
- return quarterService.reviewTo(quarterStandardVo);
- }
- @ApiOperation(value = "审核季度计划退回")
- @PostMapping("/reviewReturn")
- @Log(title = ModularConstans.planQuarter, businessType = BusinessType.UPDATE)
- public AjaxResult reviewReturn(@RequestBody PlanQuarterStandardVo quarterStandardVo, HttpServletRequest request) {
- LoginUser loginUser = tokenService.getLoginUser(request);
- quarterStandardVo.setUpdated(String.valueOf(loginUser.getUserId()));
- return quarterService.reviewReturn(quarterStandardVo);
- }
- @ApiOperation(value = "申请修改季度计划")
- @PostMapping("/appUpdate")
- @Log(title = ModularConstans.planQuarter, businessType = BusinessType.UPDATE)
- public AjaxResult appUpdate(@RequestBody PlanQuarterStandardVo quarterStandardVo) {
- return quarterService.appUpdate(quarterStandardVo);
- }
- @ApiOperation(value = "发函催告")
- @PostMapping("/sendLetter")
- @Log(title = ModularConstans.planQuarter, businessType = BusinessType.UPDATE)
- public AjaxResult sendLetter(@RequestBody PlanQuarterStandardVo quarterStandardVo) {
- return quarterService.sendLetter(quarterStandardVo);
- }
- @ApiOperation(value = "上传计划关联文件后保存文件信息")
- @PostMapping("/upLoadPlanFile")
- @Log(title = ModularConstans.planQuarter, businessType = BusinessType.OTHER)
- public AjaxResult upLoadPlanFile(@RequestBody PlanQuarterStandardVo quarterStandardVo) {
- return quarterService.upLoadPlanFile(quarterStandardVo);
- }
- //
- //@ApiOperation(value = "下载计划关联文件")
- //@PostMapping("/downLoadPlanFile")
- //public AjaxResult downLoadPlanFile(@RequestBody PlanQuarterStandardVo quarterStandardVo) {
- // return quarterService.downLoadPlanFile(quarterStandardVo);
- //}
- @ApiOperation(value = "导入季度计划数据")
- @PostMapping("/importData")
- @Log(title = ModularConstans.planQuarter, businessType = BusinessType.INSERT)
- public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception {
- ExcelUtil<PlanQuarterStandardVo> util = new ExcelUtil<>(PlanQuarterStandardVo.class);
- List<PlanQuarterStandardVo> quarter = util.importExcel(file.getInputStream());
- //获取采购单位-
- LoginUser loginUser = getLoginUser();
- String message = quarterService.importPlanQuarter(quarter, updateSupport, loginUser);
- return success(message);
- }
- }
|