123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664 |
- package com.ozs.plan.service.impl;
- import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
- import com.baomidou.mybatisplus.core.metadata.IPage;
- import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
- import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
- import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
- import com.github.pagehelper.PageInfo;
- import com.ozs.base.domain.BasePolicy;
- import com.ozs.common.constant.Constants;
- import com.ozs.common.core.domain.AjaxResult;
- import com.ozs.common.core.domain.entity.SysDept;
- import com.ozs.common.core.domain.entity.SysDictData;
- import com.ozs.common.core.domain.entity.SysRole;
- import com.ozs.common.core.domain.entity.SysUser;
- import com.ozs.common.core.domain.model.LoginUser;
- import com.ozs.common.enums.DataIsDelete;
- import com.ozs.common.enums.PmProjectStatus;
- import com.ozs.common.enums.ProjectStatus;
- import com.ozs.common.enums.ProjectTypes;
- import com.ozs.common.enums.SysFileRefEnum;
- import com.ozs.common.exception.ServiceException;
- import com.ozs.common.utils.PageUtils;
- import com.ozs.common.utils.SecurityUtils;
- import com.ozs.common.utils.StringUtils;
- import com.ozs.common.utils.bean.BeanUtils;
- import com.ozs.plan.doman.PlanYears;
- import com.ozs.plan.doman.ProvisionalPlan;
- import com.ozs.plan.doman.vo.requestVo.ProvisionalPlanVo;
- import com.ozs.plan.mapper.PlanYearsMapper;
- import com.ozs.plan.mapper.ProvisionalPlanMapper;
- import com.ozs.plan.service.ProvisionalPlanService;
- import com.ozs.pm.doman.PmAuditDeptRef;
- import com.ozs.pm.doman.PmDemand;
- import com.ozs.pm.mapper.PmDemandMapper;
- import com.ozs.pm.service.IPmDemandService;
- import com.ozs.pm.service.PmAuditDeptRefService;
- import com.ozs.system.domain.SysFileInfo;
- import com.ozs.system.domain.SysFileRef;
- import com.ozs.system.domain.vo.responseVo.SysDeptResponseVo;
- import com.ozs.system.mapper.SysDeptMapper;
- import com.ozs.system.mapper.SysFileRefMapper;
- import com.ozs.system.service.ISysDeptService;
- import com.ozs.system.service.ISysDictTypeService;
- import com.ozs.system.service.ISysUserService;
- import com.ozs.system.service.SysFileService;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- import org.springframework.transaction.annotation.Transactional;
- import org.springframework.util.ObjectUtils;
- import javax.servlet.http.HttpServletRequest;
- import java.math.BigDecimal;
- import java.text.SimpleDateFormat;
- import java.util.*;
- import java.util.stream.Collectors;
- @Service
- public class ProvisionalPlanServiceImpl extends ServiceImpl<ProvisionalPlanMapper, ProvisionalPlan> implements ProvisionalPlanService {
- @Autowired
- private ProvisionalPlanMapper provisionalPlanMapper;
- @Autowired
- private ISysDictTypeService dictTypeService;
- @Autowired
- private SysDeptMapper deptMapper;
- @Autowired
- private ISysDeptService deptService;
- @Autowired
- private PlanYearsMapper planYearsMapper;
- @Autowired
- private SysFileRefMapper sysFileRefMapper;
- @Autowired
- private SysFileService fileService;
- @Autowired
- private PmDemandMapper pmDemandMapper;
- @Autowired
- private IPmDemandService demandService;
- @Autowired
- private ISysUserService userService;
- @Autowired
- private PmAuditDeptRefService pmAuditDeptRefService;
- @Override
- public int deleteProvisionalPlanById(Long planPracticalId) {
- return provisionalPlanMapper.deleteProvisionalPlanById(planPracticalId);
- }
- @Override
- @Transactional
- public int updateProvisionalPlanById(ProvisionalPlanVo provisionalPlan) {
- //默认未超额
- if (ObjectUtils.isEmpty(provisionalPlan.getIsExcess())) {
- provisionalPlan.setIsExcess("0");
- }
- List<SysFileRef> sysFileRefs = provisionalPlan.getSysFileRefs();
- if (!ObjectUtils.isEmpty(sysFileRefs)) {
- // 删关联
- LambdaQueryWrapper<SysFileRef> lw = new LambdaQueryWrapper<>();
- lw.eq(SysFileRef::getRedId, provisionalPlan.getPlanPracticalId());
- lw.eq(SysFileRef::getType, SysFileRefEnum.PLAN_TEMPORARY.getType());
- sysFileRefMapper.delete(lw);
- for (SysFileRef ref : sysFileRefs) {
- ref.setRedId(provisionalPlan.getPlanPracticalId());
- ref.setType(SysFileRefEnum.PLAN_TEMPORARY.getType());
- ref.setCreated(provisionalPlan.getCreated());
- ref.setCreateTime(new Date());
- ref.setUpdated(provisionalPlan.getCreated());
- ref.setUpdateTime(new Date());
- sysFileRefMapper.insert(ref);
- }
- }
- return provisionalPlanMapper.updateProvisionalPlanById(provisionalPlan);
- }
- @Override
- public String importProvisionalPlan(List<ProvisionalPlan> provisionalPlans, boolean updateSupport, LoginUser loginUser) {
- // 字典项
- HashMap<String, HashMap<String, String>> planEnums = dictTypeService.getAboutEnums();
- HashMap<String, String> projectTypesMap = planEnums.get("projectTypes");
- HashMap<String, String> planPurchaseModesMap = planEnums.get("planPurchaseModes");
- HashMap<String, String> projectAttributes = planEnums.get("projectAttributes");
- // HashMap<String, String> purchaseServices = planEnums.get("purchaseServices");
- int successNum = 0;
- int failureNum = 0;
- StringBuilder successMsg = new StringBuilder();
- StringBuilder failureMsg = new StringBuilder();
- for (ProvisionalPlan ofProvisionalPlan : provisionalPlans) {
- try {
- //验证项目名称是否重复导入
- List<ProvisionalPlan> plan = provisionalPlanMapper.selectProjectName(ofProvisionalPlan.getProjectName());
- //将录入信息中的值更改为要保存的数据
- if (plan.size() == 0) {
- //采购单位
- SysDept info = deptMapper.checkDeptNameOnlyOne(ofProvisionalPlan.getPurchaseDeptName());
- if (StringUtils.isNotNull(info)) {
- ofProvisionalPlan.setPurchaseDeptId(String.valueOf(info.getDeptId()));
- }
- ofProvisionalPlan.setProjectType(projectTypesMap.get(ofProvisionalPlan.getProjectType()));
- ofProvisionalPlan.setProjectStatus(ProjectStatus.PLANWAITCOMMIT.getCode());
- ofProvisionalPlan.setPurchaseMode(planPurchaseModesMap.get(ofProvisionalPlan.getPurchaseMode()));
- //项目属性是多选字段
- StringBuilder builder = new StringBuilder();
- if (ofProvisionalPlan.getProjectAttr().contains(",")) {
- String[] split = ofProvisionalPlan.getProjectAttr().split(",");
- for (String s : split) {
- if (!ofProvisionalPlan.getProjectAttr().endsWith(s)) {
- builder.append(projectAttributes.get(s) + ",");
- } else {
- builder.append(projectAttributes.get(s));
- }
- }
- } else {
- builder.append(projectAttributes.get(ofProvisionalPlan.getProjectAttr()));
- }
- ofProvisionalPlan.setProjectAttr(builder.toString());
- // ofProvisionalPlan.setPurchaseServices(purchaseServices.get(ofProvisionalPlan.getPurchaseServicesStr()));
- ofProvisionalPlan.setIsExcess(deptService.isExcessOrNo(ofProvisionalPlan.getProjectType(), ofProvisionalPlan.getEvaluation(), info.getDeptId()));
- ofProvisionalPlan.setCreated(String.valueOf(loginUser.getUserId()));
- ofProvisionalPlan.setCreateTime(new Date());
- ofProvisionalPlan.setPlanType("1");
- provisionalPlanMapper.insert(ofProvisionalPlan);
- successNum++;
- successMsg.append("*" + successNum + "、项目 " + ofProvisionalPlan.getProjectName() + " 导入成功!");
- } else {
- failureNum++;
- failureMsg.append("*" + successNum + "、项目 " + ofProvisionalPlan.getProjectName() + " 已存在");
- }
- } catch (Exception exc) {
- failureNum++;
- String msg = "*" + successNum + "、项目 " + ofProvisionalPlan.getProjectName() + " 导入失败";
- failureMsg.append(msg + exc.getMessage());
- log.error(msg, exc);
- }
- }
- if (failureNum > 0) {
- failureMsg.insert(0, "导入失败!共 " + failureNum + " 条数据格式不正确:");
- throw new ServiceException(failureMsg.toString());
- } else {
- successMsg.insert(0, "导入成功!共 " + successNum + " 条。");
- }
- return successMsg.toString();
- }
- @Override
- public List<ProvisionalPlan> selectProvisionalPlanExport(ProvisionalPlanVo vo, LoginUser loginUser) {
- List<ProvisionalPlan> list = new ArrayList<>();
- List<ProvisionalPlan> provisionalPlanList = new ArrayList<>();
- try {
- int num = 1;
- int size = 200;
- while (size == 200) {
- LambdaQueryWrapper<ProvisionalPlan> lw = new LambdaQueryWrapper<ProvisionalPlan>();
- lw.eq(ProvisionalPlan::getPlanType, "1");
- lw.eq(ProvisionalPlan::getDelFlay, DataIsDelete.DataNOTDelete.getCode());
- if (!loginUser.getUserId().equals(Long.valueOf("1"))) {
- lw.eq(ProvisionalPlan::getPurchaseDeptId, loginUser.getDeptId());
- }
- lw.eq(ProvisionalPlan::getPlanType, "1");
- if (!ObjectUtils.isEmpty(vo.getProjectName())) {
- lw.like(ProvisionalPlan::getProjectName, vo.getProjectName());
- }
- if (!ObjectUtils.isEmpty(vo.getPurchaseServices())) {
- lw.eq(ProvisionalPlan::getPurchaseServices, vo.getPurchaseServices());
- }
- if (!ObjectUtils.isEmpty(vo.getIsExcess())) {
- lw.eq(ProvisionalPlan::getIsExcess, vo.getIsExcess());
- }
- if (!ObjectUtils.isEmpty(vo.getProjectStatus())) {
- lw.eq(ProvisionalPlan::getProjectStatus, vo.getProjectStatus());
- }
- if (!ObjectUtils.isEmpty(vo.getBeginTime())) {
- lw.ge(ProvisionalPlan::getPlanDemandSubTime, vo.getBeginTime());
- }
- if (!ObjectUtils.isEmpty(vo.getEndTime())) {
- lw.le(ProvisionalPlan::getPlanDemandSubTime, vo.getEndTime());
- }
- Page<ProvisionalPlan> page = provisionalPlanMapper.selectPage(new Page<ProvisionalPlan>(num, size, false), lw);
- list.addAll(page.getRecords());
- size = page.getRecords().size();
- num++;
- }
- provisionalPlanList = changeTo(list);
- } catch (Exception e) {
- e.printStackTrace();
- }
- return provisionalPlanList;
- }
- @Override
- @Transactional
- public int commitProvisionalPlan(ProvisionalPlanVo provisionalPlanVo) {
- ProvisionalPlan byId = provisionalPlanMapper.seletById(provisionalPlanVo.getPlanPracticalId());
- BigDecimal evaluation = byId.getEvaluation();
- SysUser sysUser = userService.selectUserById(SecurityUtils.getUserId());
- Long deptId = sysUser.getDeptId();
- if (!pmAuditDeptRefService.insertPmAuditDeptRefs(byId.getPlanPracticalId(),
- "1",
- deptId,
- evaluation,
- sysUser.getUserId(),
- byId.getProjectType())) {
- throw new ServiceException("审核关联数据插入失败");
- }
- return provisionalPlanMapper.commitProvisionalPlan(provisionalPlanVo.getPlanPracticalId());
- }
- @Override
- public AjaxResult seletById(Long planPracticalId) {
- ProvisionalPlan provisionalPlan = provisionalPlanMapper.seletById(planPracticalId);
- if (StringUtils.isNull(provisionalPlan)) {
- return AjaxResult.error("数据查询失败");
- }
- // 转换字段中文
- ProvisionalPlan provisionalPlanC = changeToProvisionalPlan(provisionalPlan);
- LambdaQueryWrapper<SysFileRef> lw = new LambdaQueryWrapper<>();
- lw.eq(SysFileRef::getRedId, provisionalPlanC.getPlanPracticalId());
- lw.in(SysFileRef::getType, Arrays.asList(SysFileRefEnum.PLAN_TEMPORARY.getType(), SysFileRefEnum.PLAN_TEMPORARY_EXAMINE.getType()));
- List<SysFileRef> fileRefs = sysFileRefMapper.selectList(lw);
- List<SysFileInfo> fileInfos = new ArrayList<>();
- ProvisionalPlanVo provisionalPlanVo = new ProvisionalPlanVo();
- BeanUtils.copyProperties(provisionalPlanC, provisionalPlanVo);
- if (!ObjectUtils.isEmpty(fileRefs)) {
- for (SysFileRef ref : fileRefs) {
- SysFileInfo fileInfo = fileService.getById(ref.getFileId());
- fileInfos.add(fileInfo);
- }
- provisionalPlanVo.setFileInfos(fileInfos);
- }
- return AjaxResult.success(provisionalPlanVo);
- }
- @Override
- public AjaxResult selectProvisionalPlan(ProvisionalPlanVo vo, HttpServletRequest request, LoginUser loginUser) {
- List<ProvisionalPlan> provisionalPlanList = new ArrayList<>();
- try {
- LambdaQueryWrapper<ProvisionalPlan> lw = new LambdaQueryWrapper<>();
- lw.eq(ProvisionalPlan::getDelFlay, DataIsDelete.DataNOTDelete.getCode());
- lw.eq(ProvisionalPlan::getPlanType, "1");
- if (!loginUser.getUserId().equals(Long.valueOf("1"))) {
- lw.eq(ProvisionalPlan::getPurchaseDeptId, loginUser.getDeptId());
- }
- if (!ObjectUtils.isEmpty(vo.getProjectName())) {
- lw.like(ProvisionalPlan::getProjectName, vo.getProjectName());
- }
- if (!ObjectUtils.isEmpty(vo.getPurchaseServices())) {
- lw.eq(ProvisionalPlan::getPurchaseServices, vo.getPurchaseServices());
- }
- if (!ObjectUtils.isEmpty(vo.getIsExcess())) {
- lw.eq(ProvisionalPlan::getIsExcess, vo.getIsExcess());
- }
- if (!ObjectUtils.isEmpty(vo.getProjectStatus())) {
- lw.eq(ProvisionalPlan::getProjectStatus, vo.getProjectStatus());
- }
- if (!ObjectUtils.isEmpty(vo.getBeginTime())) {
- lw.ge(ProvisionalPlan::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(ProvisionalPlan::getPlanDemandSubTime, parse);
- }
- lw.orderBy(true, false, ProvisionalPlan::getCreateTime);
- List<ProvisionalPlan> list = provisionalPlanMapper.selectList(lw);
- provisionalPlanList = changeTo(list);
- } catch (Exception e) {
- e.printStackTrace();
- }
- Page pages = PageUtils.getPages(vo.getPageNum().intValue(), vo.getPageSize().intValue(), provisionalPlanList);
- PageInfo<ProvisionalPlan> provisionalPlanPageInfo = new PageInfo<>();
- if (!ObjectUtils.isEmpty(pages) && pages.getRecords().size() > 0) {
- provisionalPlanPageInfo.setList(pages.getRecords());
- provisionalPlanPageInfo.setSize(Math.toIntExact(pages.getSize()));
- provisionalPlanPageInfo.setPageNum(Math.toIntExact(pages.getCurrent()));
- provisionalPlanPageInfo.setTotal(pages.getTotal());
- provisionalPlanPageInfo.setPages(Integer.parseInt(pages.getPages() + ""));
- }
- return AjaxResult.success(provisionalPlanPageInfo);
- }
- @Override
- public AjaxResult selectProvisionalPlanAudit(ProvisionalPlanVo vo, HttpServletRequest request, LoginUser loginUser) {
- List<ProvisionalPlan> provisionalPlanList = new ArrayList<>();
- try {
- LambdaQueryWrapper<ProvisionalPlan> lw = new LambdaQueryWrapper<>();
- lw.eq(ProvisionalPlan::getDelFlay, DataIsDelete.DataNOTDelete.getCode());
- lw.eq(ProvisionalPlan::getPlanType, "1");
- if (!loginUser.getUserId().equals(Long.valueOf("1"))) {
- lw.eq(ProvisionalPlan::getPurchaseDeptId, loginUser.getDeptId());
- }
- if (!ObjectUtils.isEmpty(vo.getProjectName())) {
- lw.like(ProvisionalPlan::getProjectName, vo.getProjectName());
- }
- if (!ObjectUtils.isEmpty(vo.getPurchaseServices())) {
- lw.eq(ProvisionalPlan::getPurchaseServices, vo.getPurchaseServices());
- }
- if (!ObjectUtils.isEmpty(vo.getIsExcess())) {
- lw.eq(ProvisionalPlan::getIsExcess, vo.getIsExcess());
- }
- if (!ObjectUtils.isEmpty(vo.getProjectStatus())) {
- lw.eq(ProvisionalPlan::getProjectStatus, vo.getProjectStatus());
- } else {
- lw.apply(" project_status IN (1,3)", "");
- }
- if (!ObjectUtils.isEmpty(vo.getBeginTime())) {
- lw.ge(ProvisionalPlan::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(ProvisionalPlan::getPlanDemandSubTime, parse);
- }
- lw.orderBy(true, false, ProvisionalPlan::getCreateTime);
- List<ProvisionalPlan> list = provisionalPlanMapper.selectList(lw);
- provisionalPlanList = changeTo(list);
- } catch (Exception e) {
- e.printStackTrace();
- }
- Page pages = PageUtils.getPages(vo.getPageNum().intValue(), vo.getPageSize().intValue(), provisionalPlanList);
- PageInfo<ProvisionalPlan> provisionalPlanPageInfo = new PageInfo<>();
- if (!ObjectUtils.isEmpty(pages) && pages.getRecords().size() > 0) {
- provisionalPlanPageInfo.setList(pages.getRecords());
- provisionalPlanPageInfo.setSize(Math.toIntExact(pages.getSize()));
- provisionalPlanPageInfo.setPageNum(Math.toIntExact(pages.getCurrent()));
- provisionalPlanPageInfo.setTotal(pages.getTotal());
- provisionalPlanPageInfo.setPages(Integer.parseInt(pages.getPages() + ""));
- }
- return AjaxResult.success(provisionalPlanPageInfo);
- }
- @Override
- @Transactional
- public AjaxResult auditPass(ProvisionalPlanVo provisionalPlanVo) {
- SysUser sysUser = userService.selectUserById(SecurityUtils.getUserId());
- Long deptId = sysUser.getDeptId();
- SysDept sysDept = deptMapper.selectDeptById(deptId);
- String[] ancestors = sysDept.getAncestors().split(",");
- String deptLevel = null;
- if (ancestors.length == 2) { //C级
- deptLevel = "C";
- } else if (ancestors.length == 3) { //B级
- deptLevel = "B";
- } else if (ancestors.length == 4) { //A级
- deptLevel = "A";
- }
- LambdaQueryWrapper<PmAuditDeptRef> lw = new LambdaQueryWrapper();
- lw.eq(PmAuditDeptRef::getRefId, provisionalPlanVo.getPlanPracticalId());
- lw.eq(PmAuditDeptRef::getRefType, "1");
- List<PmAuditDeptRef> list = pmAuditDeptRefService.list(lw);
- boolean flay = true;
- if (!ObjectUtils.isEmpty(list)) {
- for (PmAuditDeptRef pmAuditDeptRef : list) {
- // 判断 deptLevel 是否还有更高的 且是 待审核的数据
- if (pmAuditDeptRef.getDeptLevel().compareTo(deptLevel) > 0
- && pmAuditDeptRef.getStatus().equals(Integer.parseInt("0"))) {
- flay = false;
- }
- // 更新当前 deptLevel 级别的审核状态
- if (pmAuditDeptRef.getDeptLevel().compareTo(deptLevel) == 0) {
- pmAuditDeptRef.setStatus(1);
- pmAuditDeptRefService.updateById(pmAuditDeptRef);
- }
- }
- }
- realReviewTo(provisionalPlanVo, flay);
- return AjaxResult.success();
- }
- public AjaxResult realReviewTo(ProvisionalPlanVo provisionalPlanVo, boolean flay) {
- Date now = new Date();
- ProvisionalPlan byId = provisionalPlanMapper.seletById(provisionalPlanVo.getPlanPracticalId());
- if (ObjectUtils.isEmpty(byId.getPlanYearId())) {
- PlanYears ofYears = new PlanYears();
- BeanUtils.copyProperties(byId, ofYears);
- ofYears.setProjectStatus(ProjectStatus.PLANTOEXAMINE.getCode());
- planYearsMapper.insertPlanYears(ofYears);
- byId.setPlanYearId(ofYears.getPlanYearId());
- }
- //上传审核文件并赋予计划审核通过
- List<SysFileRef> sysFileRefss = provisionalPlanVo.getSysFileRefs();
- if (!ObjectUtils.isEmpty(sysFileRefss)) {
- for (SysFileRef ref : sysFileRefss) {
- ref.setRedId(provisionalPlanVo.getPlanPracticalId().longValue());
- ref.setType(SysFileRefEnum.PLAN_TEMPORARY_EXAMINE.getType());
- ref.setCreated(provisionalPlanVo.getUpdated());
- ref.setCreateTime(now);
- ref.setUpdated(provisionalPlanVo.getUpdated());
- ref.setUpdateTime(now);
- sysFileRefMapper.insert(ref);
- }
- }
- if (flay) {
- PmDemand demand = new PmDemand();
- BeanUtils.copyProperties(byId, demand);
- demand.setPlanId(Long.valueOf(byId.getPlanPracticalId()));
- demand.setEvaluation(byId.getEvaluation().doubleValue());
- demand.setIsExcess(Integer.parseInt(byId.getIsExcess()));
- //同步到项目管理状态为需求待填制
- demand.setProjectStatus(PmProjectStatus.DEMAND_WAIT_FILL.getCode());
- demand.setPurchaseDeptId(Long.parseLong(byId.getPurchaseDeptId()));
- demand.setCreateTime(now);
- demand.setCreateBy(provisionalPlanVo.getUpdated());
- demand.setUpdateTime(demand.getCreateTime());
- demand.setUpdateBy(demand.getCreateBy());
- demand.setIsExcess(Integer.parseInt(byId.getIsExcess()));
- provisionalPlanVo.setProjectStatus(ProjectStatus.PLANTOEXAMINE.getCode());
- provisionalPlanMapper.updateById(byId);
- pmDemandMapper.insert(demand);
- demandService.updateDemandWarnStatus(demand.getDemandId());
- //计划附件也进行同步---查询临时计划附件后复制一份改为项目需求附件
- LambdaQueryWrapper<SysFileRef> sysFileRefLp = new LambdaQueryWrapper<>();
- sysFileRefLp.eq(SysFileRef::getRedId, byId.getPlanPracticalId());
- sysFileRefLp.in(SysFileRef::getType, Arrays.asList(SysFileRefEnum.PLAN_TEMPORARY.getType(), SysFileRefEnum.PLAN_TEMPORARY_EXAMINE.getType()));
- List<SysFileRef> sysFileRefs = sysFileRefMapper.selectList(sysFileRefLp);
- if (!ObjectUtils.isEmpty(sysFileRefs)) {
- for (SysFileRef ref : sysFileRefs) {
- ref.setRedId(demand.getDemandId());
- ref.setType(SysFileRefEnum.PM_DEMAND.getType());
- ref.setId(null);
- sysFileRefMapper.insert(ref);
- }
- for (SysFileRef ref : sysFileRefs) {
- ref.setRedId(byId.getPlanYearId());
- ref.setType(SysFileRefEnum.PLAN_YEAR.getType());
- ref.setId(null);
- ref.setCreated(provisionalPlanVo.getUpdated());
- ref.setCreateTime(now);
- ref.setUpdated(provisionalPlanVo.getUpdated());
- ref.setUpdateTime(now);
- sysFileRefMapper.insert(ref);
- }
- }
- }
- return review(provisionalPlanVo);
- }
- @Override
- public AjaxResult auditNoPass(ProvisionalPlanVo provisionalPlanVo) {
- Date now = new Date();
- provisionalPlanVo.setProjectStatus(ProjectStatus.PLANTOBACK.getCode());
- //上传审核文件并赋予计划审核退回
- List<SysFileRef> sysFileRefuses = provisionalPlanVo.getSysFileRefs();
- if (!ObjectUtils.isEmpty(sysFileRefuses)) {
- for (SysFileRef ref : sysFileRefuses) {
- ref.setRedId(provisionalPlanVo.getPlanPracticalId());
- ref.setType(SysFileRefEnum.PLAN_TEMPORARY_EXAMINE.getType());
- ref.setCreated(provisionalPlanVo.getUpdated());
- ref.setCreateTime(now);
- ref.setUpdated(provisionalPlanVo.getUpdated());
- ref.setUpdateTime(now);
- sysFileRefMapper.insert(ref);
- }
- }
- return review(provisionalPlanVo);
- }
- @Override
- public List<ProvisionalPlan> queryPage(ProvisionalPlanVo vo) {
- List<ProvisionalPlan> provisionalPlanList = provisionalPlanMapper.query(vo);
- if (!ObjectUtils.isEmpty(provisionalPlanList)) {
- provisionalPlanList.stream().map(o -> {
- LambdaQueryWrapper<PmAuditDeptRef> lw = new LambdaQueryWrapper();
- lw.eq(PmAuditDeptRef::getRefId, o.getPlanPracticalId());
- lw.eq(PmAuditDeptRef::getRefType, "1");
- List<PmAuditDeptRef> list = pmAuditDeptRefService.list(lw);
- if (!ObjectUtils.isEmpty(list)) {
- List<PmAuditDeptRef> collect = list.stream()
- .filter(f -> f.getDeptId().equals(Long.valueOf(vo.getPurchaseDeptId())))
- .collect(Collectors.toList());
- String deptLevel = collect.get(0).getDeptLevel();
- boolean f = true;
- f = collect.get(0).getStatus().equals(Integer.parseInt("1")) ? false : true;
- for (PmAuditDeptRef pmAuditDeptRef : list) {
- if (pmAuditDeptRef.getDeptLevel().compareTo(deptLevel) == -1
- && pmAuditDeptRef.getStatus().equals(Integer.parseInt("0"))) {
- f = false;
- }
- }
- /*
- * String s1="A";
- String s2="B";
- System.out.println(s1.compareTo(s2));
- * over: -1
- * */
- o.setFlag(f);
- }
- return o;
- }).collect(Collectors.toList());
- }
- return provisionalPlanList;
- }
- private AjaxResult review(ProvisionalPlanVo vo) {
- int review = provisionalPlanMapper.review(vo);
- if (review != 1) {
- return AjaxResult.error("项目状态数据异常");
- }
- return AjaxResult.success();
- }
- // 字典项负值
- public ProvisionalPlan changeToProvisionalPlan(ProvisionalPlan provisionalPlan) {
- HashMap<String, HashMap<String, String>> planEnums = dictTypeService.getAboutEnums();
- HashMap<String, String> projectTypesMap = planEnums.get("projectTypes");
- HashMap<String, String> planPurchaseModesMap = planEnums.get("planPurchaseModes");
- HashMap<String, String> projectAttributes = planEnums.get("projectAttributes");
- HashMap<String, String> purchaseServices = planEnums.get("purchaseServices");
- if (provisionalPlan.getPurchaseDeptId() != null) {
- SysDeptResponseVo sysDeptResponseVo = (SysDeptResponseVo) deptService.selectDeptById(Long.valueOf(provisionalPlan.getPurchaseDeptId())).get("sysDept");
- provisionalPlan.setPurchaseDeptName(sysDeptResponseVo.getDeptName());
- }
- for (Map.Entry<String, String> entry : projectTypesMap.entrySet()) {
- if (provisionalPlan.getProjectType() != null && provisionalPlan.getProjectType().equals(entry.getValue())) {
- provisionalPlan.setProjectTypeStr(entry.getKey());
- break;
- }
- }
- for (Map.Entry<String, String> entry : planPurchaseModesMap.entrySet()) {
- if (provisionalPlan.getPurchaseMode() != null && provisionalPlan.getPurchaseMode().equals(entry.getValue())) {
- provisionalPlan.setPurchaseModeStr(entry.getKey());
- break;
- }
- }
- //项目属性是拼接的
- if (provisionalPlan.getProjectAttr().length() > 1) {
- StringBuilder builder = new StringBuilder();
- String[] split = provisionalPlan.getProjectAttr().split(",");
- for (String s : split) {
- for (Map.Entry<String, String> entry : projectAttributes.entrySet()) {
- if (s.equals(entry.getValue())) {
- builder.append(entry.getKey() + ",");
- break;
- }
- }
- }
- provisionalPlan.setProjectAttrStr(builder.toString());
- } else {
- for (Map.Entry<String, String> entry : projectAttributes.entrySet()) {
- if (provisionalPlan.getProjectAttr() != null && provisionalPlan.getProjectAttr().equals(entry.getValue())) {
- provisionalPlan.setProjectAttrStr(entry.getKey());
- break;
- }
- }
- }
- /*for (Map.Entry<String, String> entry : purchaseServices.entrySet()) {
- if (provisionalPlan.getPurchaseServices() != null && provisionalPlan.getPurchaseServices().equals(entry.getValue())) {
- provisionalPlan.setPurchaseServicesStr(entry.getKey());
- break;
- }
- }*/
- return provisionalPlan;
- }
- //字段赋值对应的名称
- public List<ProvisionalPlan> changeTo(List<ProvisionalPlan> provisionalPlans) {
- HashMap<String, HashMap<String, String>> planEnums = dictTypeService.getAboutEnums();
- HashMap<String, String> projectTypesMap = planEnums.get("projectTypes");
- HashMap<String, String> planPurchaseModesMap = planEnums.get("planPurchaseModes");
- HashMap<String, String> projectAttributes = planEnums.get("projectAttributes");
- HashMap<String, String> purchaseServices = planEnums.get("purchaseServices");
- List<ProvisionalPlan> list = new ArrayList<ProvisionalPlan>();
- for (ProvisionalPlan provisionalPlan : provisionalPlans) {
- if (provisionalPlan.getPurchaseDeptId() != null) {
- SysDeptResponseVo sysDeptResponseVo = (SysDeptResponseVo) deptService.selectDeptById(Long.valueOf(provisionalPlan.getPurchaseDeptId())).get("sysDept");
- provisionalPlan.setPurchaseDeptName(sysDeptResponseVo.getDeptName());
- }
- for (Map.Entry<String, String> entry : projectTypesMap.entrySet()) {
- if (provisionalPlan.getProjectType() != null && provisionalPlan.getProjectType().equals(entry.getValue())) {
- provisionalPlan.setProjectTypeStr(entry.getKey());
- break;
- }
- }
- for (Map.Entry<String, String> entry : planPurchaseModesMap.entrySet()) {
- if (provisionalPlan.getPurchaseMode() != null && provisionalPlan.getPurchaseMode().equals(entry.getValue())) {
- provisionalPlan.setPurchaseModeStr(entry.getKey());
- break;
- }
- }
- //项目属性是拼接的
- if (provisionalPlan.getProjectAttr().length() > 1) {
- StringBuilder builder = new StringBuilder();
- String[] split = provisionalPlan.getProjectAttr().split(",");
- for (String s : split) {
- for (Map.Entry<String, String> entry : projectAttributes.entrySet()) {
- if (s.equals(entry.getValue())) {
- builder.append(entry.getKey() + ",");
- break;
- }
- }
- }
- provisionalPlan.setProjectAttrStr(builder.toString());
- } else {
- for (Map.Entry<String, String> entry : projectAttributes.entrySet()) {
- if (provisionalPlan.getProjectAttr() != null && provisionalPlan.getProjectAttr().equals(entry.getValue())) {
- provisionalPlan.setProjectAttrStr(entry.getKey());
- break;
- }
- }
- }
- // 采购服务站
- // for (Map.Entry<String, String> entry : purchaseServices.entrySet()) {
- // if (provisionalPlan.getPurchaseServices() != null && provisionalPlan.getPurchaseServices().equals(entry.getValue())) {
- // provisionalPlan.setPurchaseServicesStr(entry.getKey());
- // break;
- // }
- // }
- list.add(provisionalPlan);
- }
- return list;
- }
- }
|