12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070 |
- package com.ozs.plan.service.impl;
- import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
- import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
- import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
- 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.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.QuarterEnum;
- import com.ozs.common.enums.SysFileRefEnum;
- import com.ozs.common.exception.ServiceException;
- import com.ozs.common.utils.DateUtils;
- import com.ozs.common.utils.SecurityUtils;
- import com.ozs.common.utils.StringUtils;
- import com.ozs.common.utils.bean.BeanUtils;
- import com.ozs.plan.doman.PlanQuarter;
- import com.ozs.plan.doman.PlanYears;
- import com.ozs.plan.doman.vo.requestVo.PlanQuarterStandardVo;
- import com.ozs.plan.doman.vo.responseVo.PlanQuarterResponseVo;
- import com.ozs.plan.mapper.PlanQuarterMapper;
- import com.ozs.plan.mapper.PlanYearsMapper;
- import com.ozs.plan.service.PlanQuarterService;
- import com.ozs.pm.doman.PmAuditDeptRef;
- import com.ozs.pm.doman.PmDemand;
- import com.ozs.pm.mapper.PmAuditDeptRefMapper;
- import com.ozs.pm.mapper.PmDemandMapper;
- import com.ozs.pm.service.IPmDemandService;
- import com.ozs.pm.service.PmAuditDeptRefService;
- import com.ozs.system.domain.SysDeptOrgan;
- 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.SysDeptOrganMapper;
- import com.ozs.system.mapper.SysFileRefMapper;
- import com.ozs.system.service.ISysDeptService;
- import com.ozs.system.service.ISysDictDataService;
- import com.ozs.system.service.ISysDictTypeService;
- import com.ozs.system.service.ISysUserService;
- import com.ozs.system.service.SysFileService;
- import lombok.extern.slf4j.Slf4j;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.security.core.token.TokenService;
- import org.springframework.stereotype.Service;
- import org.springframework.transaction.annotation.Transactional;
- import org.springframework.util.ObjectUtils;
- import javax.validation.Validator;
- import java.math.BigDecimal;
- import java.text.ParseException;
- import java.text.SimpleDateFormat;
- import java.util.ArrayList;
- import java.util.Arrays;
- import java.util.Calendar;
- import java.util.Date;
- import java.util.HashMap;
- import java.util.LinkedHashMap;
- import java.util.LinkedList;
- import java.util.List;
- import java.util.Map;
- import java.util.stream.Collectors;
- /**
- * @author buzhanyi
- */
- @Service
- @Slf4j
- public class PlanQuarterServiceImpl extends ServiceImpl<PlanQuarterMapper, PlanQuarter> implements PlanQuarterService {
- @Autowired
- PlanQuarterMapper planQuarterMapper;
- @Autowired
- PlanYearsMapper planYearsMapper;
- @Autowired
- protected Validator validator;
- @Autowired
- private ISysDictTypeService dictTypeService;
- @Autowired
- private ISysDeptService deptService;
- @Autowired
- SysFileRefMapper sysFileRefMapper;
- @Autowired
- private SysDeptMapper deptMapper;
- @Autowired
- private SysFileService fileService;
- @Autowired
- private PmDemandMapper pmDemandMapper;
- @Autowired
- private IPmDemandService demandService;
- @Autowired
- private ISysUserService userService;
- @Autowired
- private PmAuditDeptRefService pmAuditDeptRefService;
- @Autowired
- private PmAuditDeptRefMapper pmAuditDeptRefMapper;
- @Autowired
- private SysDeptOrganMapper sysDeptOrganMapper;
- @Override
- public List<PlanQuarterResponseVo> selectPlanQuarterListEXP(PlanQuarterStandardVo vo, LoginUser loginUser) {
- List<PlanQuarter> list = new ArrayList<>();
- List<PlanQuarterResponseVo> planQuarterList = new ArrayList<>();
- try {
- int num = 1;
- int size = 200;
- while (size == 200) {
- LambdaQueryWrapper<PlanQuarter> lw = new LambdaQueryWrapper<>();
- if (!loginUser.getUserId().equals(Long.valueOf("1"))) {
- lw.eq(PlanQuarter::getCreated, loginUser.getUserId());
- //lw.eq(PlanQuarter::getPurchaseDeptId, loginUser.getDeptId());
- }
- lw.eq(PlanQuarter::getPlanType, "0");
- 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.getProjectStatus())) {
- lw.eq(PlanQuarter::getProjectStatus, vo.getProjectStatus());
- }
- if (!ObjectUtils.isEmpty(vo.getParams())) {
- if (!ObjectUtils.isEmpty(vo.getParams().get("beginTime"))) {
- SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM");
- Date ofMonth = dateFormat.parse(vo.getParams().get("beginTime").toString() + "-01");
- lw.ge(PlanQuarter::getPlanDemandSubTime, ofMonth);
- }
- if (!ObjectUtils.isEmpty(vo.getParams().get("endTime"))) {
- SimpleDateFormat dateFormaH = new SimpleDateFormat("yyyy-MM");
- SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
- SimpleDateFormat dateFormatT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");
- Date ofMonth = DateUtils.getLastDayOfMonth(dateFormaH.parse(vo.getParams().get("endTime").toString()));
- Date parse = dateFormatT.parse(dateFormat.format(ofMonth) + " 23:59:59:999");
- lw.le(PlanQuarter::getPlanDemandSubTime, parse);
- }
- }
- lw.eq(PlanQuarter::getDelFlay, DataIsDelete.DataNOTDelete.getCode());
- Page<PlanQuarter> page = planQuarterMapper.selectPage(new Page<>(num, size, false), lw);
- list.addAll(page.getRecords());
- size = page.getRecords().size();
- num++;
- }
- planQuarterList = changeTo(list);
- } catch (Exception e) {
- e.printStackTrace();
- }
- return planQuarterList;
- }
- @Override
- public List<PlanQuarterResponseVo> selectPlanQuarterExamineListEXP(PlanQuarterStandardVo vo, LoginUser loginUser) {
- List<PlanQuarter> list = new ArrayList<>();
- List<PlanQuarterResponseVo> planQuarterList = new ArrayList<>();
- try {
- int num = 1;
- int size = 200;
- while (size == 200) {
- LambdaQueryWrapper<PlanQuarter> lw = new LambdaQueryWrapper<PlanQuarter>();
- if (!loginUser.getUserId().equals(Long.valueOf("1"))) {
- lw.eq(PlanQuarter::getPurchaseDeptId, loginUser.getDeptId());
- }
- lw.eq(PlanQuarter::getPlanType, "0");
- 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.getProjectStatus())) {
- lw.eq(PlanQuarter::getProjectStatus, vo.getProjectStatus());
- } else {
- lw.in(PlanQuarter::getProjectStatus, "1,3,4");
- }
- if (!ObjectUtils.isEmpty(vo.getParams())) {
- if (!ObjectUtils.isEmpty(vo.getParams().get("beginTime"))) {
- lw.ge(PlanQuarter::getPlanDemandSubTime, vo.getParams().get("beginTime"));
- }
- if (!ObjectUtils.isEmpty(vo.getParams().get("endTime"))) {
- SimpleDateFormat dateFormatT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");
- Date parse = dateFormatT.parse(vo.getParams().get("endTime").toString() + " 23:59:59:999");
- lw.le(PlanQuarter::getPlanDemandSubTime, parse);
- }
- }
- lw.eq(PlanQuarter::getDelFlay, DataIsDelete.DataNOTDelete.getCode());
- Page<PlanQuarter> page = planQuarterMapper.selectPage(new Page<PlanQuarter>(num, size, false), lw);
- list.addAll(page.getRecords());
- size = page.getRecords().size();
- num++;
- }
- planQuarterList = changeTo(list);
- } catch (Exception e) {
- e.printStackTrace();
- }
- return planQuarterList;
- }
- @Transactional
- @Override
- public AjaxResult insertPlanQuarter(PlanQuarterStandardVo quarterStandardVo) {
- if (planQuarterMapper.countProjectName(quarterStandardVo.getProjectName()) > 0) {
- return AjaxResult.error("该项目名称已经存在");
- }
- //默认未超额
- PlanQuarter quarters = new PlanQuarter();
- try {
- BeanUtils.copyProperties(quarterStandardVo, quarters);
- } catch (Exception e) {
- e.printStackTrace();
- }
- quarters.setProjectStatus(ProjectStatus.PLANWAITCOMMIT.getCode());
- quarters.setCreateTime(new Date());
- planQuarterMapper.insertPlanQuarter(quarters);
- log.info("id:{}", quarters.getPlanPracticalId());
- List<SysFileRef> sysFileRefs = quarterStandardVo.getSysFileRefs();
- if (!ObjectUtils.isEmpty(sysFileRefs)) {
- for (SysFileRef ref : sysFileRefs) {
- ref.setRedId(quarters.getPlanPracticalId());
- ref.setType(SysFileRefEnum.PLAN_TEMPORARY.getType());
- ref.setCreated(quarters.getCreated());
- ref.setCreateTime(new Date());
- ref.setUpdated(quarters.getCreated());
- ref.setUpdateTime(new Date());
- sysFileRefMapper.insert(ref);
- }
- }
- return AjaxResult.success();
- }
- @Override
- public AjaxResult deletePlanQuarterByIds(Long[] planIds) {
- planQuarterMapper.deletePlanQuarterByIds(planIds);
- return AjaxResult.success();
- }
- @Override
- public AjaxResult deletePlanQuarterById(Long planId) {
- planQuarterMapper.deletePlanQuarterById(planId);
- return AjaxResult.success();
- }
- @Override
- public AjaxResult view(PlanQuarterStandardVo quarterStandardVo) {
- PlanQuarterResponseVo responseVo = new PlanQuarterResponseVo();
- PlanQuarter byId = planQuarterMapper.getById(quarterStandardVo.getPlanPracticalId());
- if (byId == null) {
- return AjaxResult.error("数据查询失败");
- }
- SysDeptResponseVo sysDeptResponseVo = (SysDeptResponseVo) deptService.selectDeptById(Long.valueOf(byId.getPurchaseDeptId())).get("sysDept");
- byId.setPurchaseDeptName(sysDeptResponseVo.getDeptName());
- LambdaQueryWrapper<SysFileRef> lw = new LambdaQueryWrapper<>();
- lw.eq(SysFileRef::getRedId, quarterStandardVo.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<>();
- BeanUtils.copyProperties(byId, responseVo);
- if (!ObjectUtils.isEmpty(fileRefs)) {
- for (SysFileRef ref : fileRefs) {
- SysFileInfo fileInfo = fileService.getById(ref.getFileId());
- fileInfos.add(fileInfo);
- }
- responseVo.setFileInfos(fileInfos);
- }
- String organDivision = byId.getOrganDivision();
- if (!ObjectUtils.isEmpty(organDivision)) {
- int length = organDivision.split(",").length;
- SysDeptOrgan organ = new SysDeptOrgan();
- if (length > 1) {
- StringBuilder builder = new StringBuilder();
- String[] split = organDivision.split(",");
- for (String s : split) {
- organ = sysDeptOrganMapper.selectById(s);
- if (!ObjectUtils.isEmpty(organ)) {
- if (!organDivision.endsWith(s)) {
- builder.append(organ.getOrganName() + ",");
- } else {
- builder.append(organ.getOrganName());
- }
- }
- }
- responseVo.setOrganDivisionStr(builder.toString());
- } else if (length == 1) {
- organ = sysDeptOrganMapper.selectById(organDivision);
- if (!ObjectUtils.isEmpty(organ)) {
- responseVo.setOrganDivisionStr(organ.getOrganName());
- }
- }
- }
- return AjaxResult.success(responseVo);
- }
- @Transactional
- @Override
- public AjaxResult update(PlanQuarterStandardVo quarterStandardVo) {
- Date now = new Date();
- if (planQuarterMapper.countProjectNameOther(quarterStandardVo.getProjectName(), String.valueOf(quarterStandardVo.getPlanPracticalId())) > 0) {
- return AjaxResult.error("该项目名称已经存在");
- }
- PlanQuarter quarters = new PlanQuarter();
- try {
- BeanUtils.copyProperties(quarterStandardVo, quarters);
- } catch (Exception e) {
- e.printStackTrace();
- }
- quarters.setUpdateTime(now);
- PlanQuarter byId = planQuarterMapper.selectById(quarters.getPlanPracticalId());
- //临时计划修改后要更新年度计划
- if (byId.getPlanType().equals(Integer.parseInt("1"))) {
- if (!ObjectUtils.isEmpty(planYearsMapper.selectById(byId.getPlanYearId()))) {
- PlanYears years = new PlanYears();
- BeanUtils.copyProperties(quarterStandardVo, years);
- years.setProjectAttr(null);
- years.setPlanYearId(null);
- planYearsMapper.updateById(years);
- }
- }
- planQuarterMapper.updateById(quarters);
- List<SysFileRef> sysFileRefs = quarterStandardVo.getSysFileRefs();
- if (!ObjectUtils.isEmpty(sysFileRefs)) {
- // 删关联
- LambdaQueryWrapper<SysFileRef> lw = new LambdaQueryWrapper<>();
- lw.eq(SysFileRef::getRedId, quarters.getPlanPracticalId());
- lw.eq(SysFileRef::getType, SysFileRefEnum.PLAN_TEMPORARY.getType());
- sysFileRefMapper.delete(lw);
- for (SysFileRef ref : sysFileRefs) {
- ref.setRedId(quarters.getPlanPracticalId());
- ref.setType(SysFileRefEnum.PLAN_TEMPORARY.getType());
- ref.setCreated(quarterStandardVo.getUpdated());
- ref.setCreateTime(now);
- ref.setUpdated(quarterStandardVo.getUpdated());
- ref.setUpdateTime(now);
- sysFileRefMapper.insert(ref);
- }
- }
- return AjaxResult.success();
- }
- @Override
- public String importPlanQuarter(List<PlanQuarterStandardVo> planQuarters, boolean isUpdateSupport, LoginUser loginUser) {
- if (StringUtils.isNull(planQuarters) || planQuarters.size() == 0) {
- throw new ServiceException("导入季度计划数据不能为空!");
- }
- List<PlanQuarter> list = new ArrayList<>();
- for (PlanQuarterStandardVo standardVo : planQuarters) {
- PlanQuarter quarter = new PlanQuarter();
- BeanUtils.copyProperties(standardVo, quarter);
- quarter.setPurchaseDeptName(standardVo.getPurchaseDeptId());
- list.add(quarter);
- }
- HashMap<String, HashMap<String, String>> planEnums = dictTypeService.getAboutEnums();
- HashMap<String, String> projectTypesMap = planEnums.get("projectTypes");
- HashMap<String, String> projectAttributes = planEnums.get("projectAttributes");
- int successNum = 0;
- int failureNum = 0;
- StringBuilder successMsg = new StringBuilder();
- StringBuilder failureMsg = new StringBuilder();
- //deptService
- for (PlanQuarter planQuarter : list) {
- try {
- //验证项目名称是否重复导入
- //将录入信息中的值更改为要保存的数据
- if (planQuarterMapper.countProjectName(planQuarter.getProjectName()) == 0) {
- //采购单位
- SysDept info = deptMapper.checkDeptNameOnlyOne(planQuarter.getPurchaseDeptName());
- if (!ObjectUtils.isEmpty(info)) {
- planQuarter.setPurchaseDeptId(String.valueOf(info.getDeptId()));
- } else {
- ++failureNum;
- failureMsg.append("*" + failureNum + "*采购单位“" + planQuarter.getPurchaseDeptName() + "”不存在 <br/>");
- }
- planQuarter.setProjectType(projectTypesMap.get(planQuarter.getProjectType()));
- planQuarter.setProjectStatus(ProjectStatus.PLANWAITCOMMIT.getCode());
- //项目属性是多选字段
- StringBuilder builder = new StringBuilder();
- if (planQuarter.getProjectAttr().contains(",")) {
- String[] split = planQuarter.getProjectAttr().split(",");
- for (String s : split) {
- if (!planQuarter.getProjectAttr().endsWith(s)) {
- builder.append(projectAttributes.get(s) + ",");
- } else {
- builder.append(projectAttributes.get(s));
- }
- }
- } else {
- builder.append(projectAttributes.get(planQuarter.getProjectAttr()));
- }
- planQuarter.setProjectAttr(builder.toString());
- planQuarter.setCreated(String.valueOf(loginUser.getUserId()));
- planQuarter.setCreateTime(new Date());
- planQuarterMapper.insertPlanQuarter(planQuarter);
- successNum++;
- successMsg.append("*" + successNum + "、项目 " + planQuarter.getProjectName() + " 导入成功!<br/>");
- } else {
- failureNum++;
- failureMsg.append(failureNum + "*项目 " + planQuarter.getProjectName() + " 已存在!<br/>");
- }
- } catch (Exception exc) {
- String msg = " *" + successNum + "*项目 " + planQuarter.getProjectName() + " 导入失败 <br/>";
- failureMsg.append(msg);
- log.error(msg, exc);
- }
- }
- if (failureNum > 0) {
- failureMsg.insert(0, "导入失败!共 " + failureNum + " 条数据格式不正确: <br/>");
- throw new ServiceException(failureMsg.toString());
- } else {
- successMsg.insert(0, "导入成功!共 " + successNum + " 条。<br/>");
- }
- return successMsg.toString();
- }
- @Override
- @Transactional
- public AjaxResult commit(PlanQuarterStandardVo quarterStandardVo) {
- PlanQuarter byId = planQuarterMapper.getById(quarterStandardVo.getPlanPracticalId());
- if (!isBetweenValue(byId)) {
- return AjaxResult.error("所创计划不在提报日期内!");
- }
- //申请修改之后再次提交,先清除上一次提交后的审核记录
- PmAuditDeptRef ref = new PmAuditDeptRef();
- ref.setRefId(byId.getPlanPracticalId());
- ref.setRefType("1");
- ref.setProjectType(byId.getProjectType());
- ref.setEvaluation(byId.getEvaluation());
- refIsExist(ref, pmAuditDeptRefMapper);
- insertAuditDeptRef(userService, pmAuditDeptRefService, ref);
- int commit = planQuarterMapper.commit(quarterStandardVo.getPlanPracticalId());
- if (commit != 1) {
- return AjaxResult.error("项目状态数据异常");
- }
- return AjaxResult.success();
- }
- //是否已存在--关联审核部门
- static void refIsExist(PmAuditDeptRef ref, PmAuditDeptRefMapper pmAuditDeptRefMapper) {
- LambdaQueryWrapper<PmAuditDeptRef> lp = new LambdaQueryWrapper<>();
- lp.eq(PmAuditDeptRef::getRefId, ref.getRefId());
- lp.eq(PmAuditDeptRef::getRefType, ref.getRefType());
- List<PmAuditDeptRef> refs = pmAuditDeptRefMapper.selectList(lp);
- if (!ObjectUtils.isEmpty(refs)) {
- pmAuditDeptRefMapper.delete(lp);
- }
- }
- static void insertAuditDeptRef(ISysUserService userService, PmAuditDeptRefService pmAuditDeptRefService, PmAuditDeptRef ref) {
- SysUser sysUser = userService.selectUserById(SecurityUtils.getUserId());
- Long deptId = sysUser.getDeptId();
- if (!pmAuditDeptRefService.insertPmAuditDeptRefs(ref.getRefId(),
- ref.getRefType(),
- deptId,
- ref.getEvaluation(),
- sysUser.getUserId(),
- ref.getProjectType())) {
- throw new ServiceException("审核关联数据插入失败");
- }
- }
- @Override
- @Transactional
- public AjaxResult reviewTo(PlanQuarterStandardVo vo) {
- 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, vo.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(vo, flay);
- return AjaxResult.success();
- }
- public AjaxResult realReviewTo(PlanQuarterStandardVo vo, boolean flay) {
- Date now = new Date();
- //季度计划审核通过后同步到年度计划和项目管理
- PlanQuarter byId = planQuarterMapper.getById(vo.getPlanPracticalId());
- //上传审核文件并赋予计划审核通过
- upExamineFile(vo);
- if (flay) {
- //同步到项目管理
- PmDemand demand = new PmDemand();
- BeanUtils.copyProperties(byId, demand);
- demand.setEvaluation(byId.getEvaluation().doubleValue());
- demand.setPlanId(byId.getPlanPracticalId());
- demand.setPurchaseDeptId(Long.valueOf(byId.getPurchaseDeptId()));
- //同步到项目管理状态为需求待填制
- demand.setProjectStatus(PmProjectStatus.DEMAND_WAIT_FILL.getCode());
- demand.setCreateTime(now);
- demand.setCreateBy(byId.getCreated());
- demand.setUpdateTime(now);
- demand.setUpdateBy(demand.getCreateBy());
- pmDemandMapper.insert(demand);
- demandService.updateDemandWarnStatus(demand.getDemandId());
- //计划附件也进行同步---查询季度计划附件后同步到项目需求附件和年度计划附件
- LambdaQueryWrapper<SysFileRef> sysFileRefLp = new LambdaQueryWrapper<>();
- sysFileRefLp.eq(SysFileRef::getRedId, vo.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);
- ref.setCreated(vo.getUpdated());
- ref.setCreateTime(now);
- ref.setUpdated(vo.getUpdated());
- ref.setUpdateTime(now);
- sysFileRefMapper.insert(ref);
- }
- }
- //赋予项目状态已审核
- vo.setProjectStatus(ProjectStatus.PLANTOEXAMINE.getCode());
- return review(vo);
- }
- return AjaxResult.success("成功");
- }
- @Override
- @Transactional
- public AjaxResult reviewReturn(PlanQuarterStandardVo vo) {
- vo.setProjectStatus(ProjectStatus.PLANTOBACK.getCode());
- //上传审核文件并赋予计划审核退回
- upExamineFile(vo);
- return review(vo);
- }
- /**
- * 上传审核文件
- *
- * @param vo
- */
- @Override
- @Transactional
- public void upExamineFile(PlanQuarterStandardVo vo) {
- Date now = new Date();
- List<SysFileRef> sysFileRefuses = vo.getSysFileRefs();
- if (!ObjectUtils.isEmpty(sysFileRefuses)) {
- for (SysFileRef ref : sysFileRefuses) {
- ref.setRedId(vo.getPlanPracticalId());
- ref.setType(SysFileRefEnum.PLAN_TEMPORARY_EXAMINE.getType());
- ref.setCreated(vo.getUpdated());
- ref.setCreateTime(now);
- ref.setUpdated(vo.getUpdated());
- ref.setUpdateTime(now);
- sysFileRefMapper.insert(ref);
- }
- }
- }
- private AjaxResult review(PlanQuarterStandardVo vo) {
- int review = planQuarterMapper.review(vo);
- if (review != 1) {
- return AjaxResult.error("项目状态数据异常");
- }
- return AjaxResult.success();
- }
- @Override
- public AjaxResult appUpdate(PlanQuarterStandardVo vo) {
- //申请后会成为未提交的状态,可以进行修改
- PlanQuarter planQuarter = new PlanQuarter();
- BeanUtils.copyProperties(vo, planQuarter);
- planQuarter.setAppUpdate("true");
- planQuarterMapper.updateById(planQuarter);
- return AjaxResult.success("申请成功");
- }
- @Override
- @Transactional
- public AjaxResult handleAppUpdate(PlanQuarterStandardVo vo) {
- //getProjectAttr传值1为同意。-1为拒绝
- PlanQuarter planQuarter = new PlanQuarter();
- planQuarter.setPlanPracticalId(vo.getPlanPracticalId());
- //同意修改申请
- if ("1".equals(vo.getProjectAttr())) {
- //同意申请之后进行修改,提交后可再次申请
- planQuarter.setAppUpdate("");
- planQuarter.setProjectStatus(ProjectStatus.PLANWAITCOMMIT.getCode());
- planQuarterMapper.updateById(planQuarter);
- return AjaxResult.success("已同意该修改申请");
- }
- //拒绝后可以再次申请
- planQuarter.setAppUpdate("");
- planQuarterMapper.updateById(planQuarter);
- return AjaxResult.success("已拒绝改申请");
- }
- @Override
- public AjaxResult sendLetter(PlanQuarterStandardVo quarterStandardVo) {
- PlanQuarter quarter = new PlanQuarter();
- BeanUtils.copyProperties(quarterStandardVo, quarter);
- quarter.setSendLetter("1");
- quarter.setLetterTime(new Date());
- int review = planQuarterMapper.updateById(quarter);
- if (review != 1) {
- return AjaxResult.error("项目状态数据异常");
- }
- return AjaxResult.success();
- }
- @Override
- public AjaxResult upLoadPlanFile(PlanQuarterStandardVo quarterStandardVo) {
- List<SysFileRef> sysFileRefs = quarterStandardVo.getSysFileRefs();
- if (!ObjectUtils.isEmpty(sysFileRefs)) {
- for (SysFileRef ref : sysFileRefs) {
- ref.setRedId(quarterStandardVo.getPlanPracticalId());
- ref.setType(SysFileRefEnum.PLAN_TEMPORARY.getType());
- sysFileRefMapper.insert(ref);
- }
- }
- return AjaxResult.success();
- }
- @Override
- public List<PlanQuarter> queryPage(PlanQuarterStandardVo vo) {
- LoginUser loginUser = SecurityUtils.getLoginUser();
- if (!loginUser.getUserId().equals(Long.valueOf("1")) && StringUtils.isEmpty(vo.getPurchaseDeptId())) {
- vo.setPurchaseDeptId(String.valueOf(loginUser.getDeptId()));
- }
- List<PlanQuarter> query = planQuarterMapper.query(vo);
- List<PlanQuarter> queryTwo = new LinkedList<>();
- if (!ObjectUtils.isEmpty(query)) {
- for (PlanQuarter quarter : query) {
- LambdaQueryWrapper<PmAuditDeptRef> lw = new LambdaQueryWrapper();
- lw.eq(PmAuditDeptRef::getRefId, quarter.getPlanPracticalId());
- lw.eq(PmAuditDeptRef::getRefType, "1");
- List<PmAuditDeptRef> list = pmAuditDeptRefService.list(lw);
- //是否显示审核按钮
- boolean fl = true;
- //是否为本单位已审核过的数据
- boolean fg = false;
- if (!ObjectUtils.isEmpty(list) && list.size() > 0) {
- List<PmAuditDeptRef> collect = list.stream()
- .filter(f -> f.getDeptId().equals(Long.valueOf(vo.getPurchaseDeptId())))
- .collect(Collectors.toList());
- if (ObjectUtils.isEmpty(collect)) {
- fl = false;
- } else {
- String deptLevel = collect.get(0).getDeptLevel();
- fl = 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"))) {
- fl = false;
- }
- //本单位已审核
- if (pmAuditDeptRef.getDeptLevel().compareTo(deptLevel) == 0
- && pmAuditDeptRef.getStatus().equals(Integer.parseInt("1"))) {
- fg = true;
- }
- }
- }
- /*
- * String s1="A";
- String s2="B";
- System.out.println(s1.compareTo(s2));
- * over: -1
- * */
- }
- if (vo.getCreated().equals("1")) {
- fl = false;
- }
- quarter.setFlag(fl);
- if (fl == true || quarter.getPurchaseDeptId().equals(vo.getPurchaseDeptId())) {
- queryTwo.add(quarter);
- } else if (fg == true) {
- queryTwo.add(quarter);
- }
- }
- }
- return queryTwo;
- }
- /**
- * 导入年度计划数据
- *
- * @param planYearIds
- * @return
- */
- @Override
- @Transactional
- public AjaxResult importPlanYearsData(List<Long> planYearIds) {
- Date now = new Date();
- StringBuilder sb = new StringBuilder("项目【'");
- for (Long yearId : planYearIds) {
- PlanQuarter byPlanYearId = planQuarterMapper.getByPlanYearId(yearId);
- if (!ObjectUtils.isEmpty(byPlanYearId)) {
- sb.append(byPlanYearId.getProjectName() + "'、'");
- } else {
- PlanQuarter quarter = new PlanQuarter();
- PlanYears years = planYearsMapper.getById(yearId);
- BeanUtils.copyProperties(years, quarter);
- quarter.setPlanYearId(yearId);
- quarter.setPlanType(0);
- quarter.setProjectStatus(ProjectStatus.PLANWAITCOMMIT.getCode());
- planQuarterMapper.insert(quarter);
- //项目上传附件和审核文件进行同步
- LambdaQueryWrapper<SysFileRef> lw = new LambdaQueryWrapper<>();
- lw.eq(SysFileRef::getRedId, years.getPlanYearId());
- lw.in(SysFileRef::getType, Arrays.asList(SysFileRefEnum.PLAN_YEAR.getType(), SysFileRefEnum.PLAN_YEAR_EXAMINE.getType()));
- List<SysFileRef> fileRefs = sysFileRefMapper.selectList(lw);
- for (SysFileRef fileRef : fileRefs) {
- fileRef.setId(null);
- fileRef.setRedId(quarter.getPlanPracticalId());
- fileRef.setType(SysFileRefEnum.PLAN_TEMPORARY.getType());
- fileRef.setCreateTime(now);
- fileRef.setCreated(SecurityUtils.getUserId() + "");
- sysFileRefMapper.insert(fileRef);
- }
- }
- }
- sb.append("】已存在,请勿选择。");
- if (sb.length() > 14) {
- return AjaxResult.error(sb.toString());
- }
- return AjaxResult.success();
- }
- @Override
- public AjaxResult appDelete(PlanQuarterStandardVo quarterStandardVo) {
- PlanQuarter planQuarter = new PlanQuarter();
- BeanUtils.copyProperties(quarterStandardVo, planQuarter);
- planQuarter.setAppDelete("true");
- planQuarterMapper.updateById(planQuarter);
- return AjaxResult.success("申请成功");
- }
- @Override
- public AjaxResult handleApp(PlanQuarterStandardVo quarterStandardVo) {
- //getProjectAttr传值1为同意。-1为拒绝
- if ("1".equals(quarterStandardVo.getProjectAttr())) {
- planQuarterMapper.deletePlanQuarterById(quarterStandardVo.getPlanPracticalId());
- return AjaxResult.success("已成功进行撤销");
- }
- PlanQuarter planQuarter = new PlanQuarter();
- planQuarter.setPlanPracticalId(quarterStandardVo.getPlanPracticalId());
- planQuarter.setAppDelete("false");
- planQuarterMapper.updateById(planQuarter);
- return AjaxResult.success("已拒绝改申请");
- }
- //字段赋值对应的名称
- public List<PlanQuarterResponseVo> changeTo(List<PlanQuarter> planQuarters) {
- //获取季度计划各个季度提报时间的阈值
- List<SysDictData> supTime = dictTypeService.selectDictDataByType("sys_quarterly_plan");
- HashMap<String, String> thresholdMap = new LinkedHashMap<>();
- //各个季度提报时间的阈值
- for (SysDictData dictData : supTime) {
- // 季度----阈值
- thresholdMap.put(dictData.getDictLabel(), dictData.getDictValue());
- }
- //提前或延后*天进行提醒
- List<SysDictData> alertTime = dictTypeService.selectDictDataByType("alert_time_setting");
- HashMap<String, String> alertTimeMap = new LinkedHashMap<>();
- //根据时间类别设定的提醒时间
- for (SysDictData dictData : alertTime) {
- // 字段名称----阈值
- alertTimeMap.put(dictData.getDictLabel(), dictData.getDictValue());
- }
- //获取字典数据
- HashMap<String, HashMap<String, String>> planEnums = dictTypeService.getAboutEnums();
- //项目属性
- HashMap<String, String> projectAttributes = planEnums.get("projectAttributes");
- //项目审核状态
- HashMap<String, String> projectStatusMap = planEnums.get("projectStatus");
- //项目类型
- HashMap<String, String> projectTypesMap = planEnums.get("projectTypes");
- //预算科目
- HashMap<String, String> budgetAccountMap = planEnums.get("budgetAccount");
- //采购服务站
- HashMap<String, String> purchaseServicesMap = planEnums.get("purchaseServices");
- List<PlanQuarterResponseVo> list = new ArrayList<PlanQuarterResponseVo>();
- for (PlanQuarter planQuarter : planQuarters) {
- PlanQuarterResponseVo responseVo = new PlanQuarterResponseVo();
- SysDeptResponseVo sysDeptResponseVo = (SysDeptResponseVo) deptService.selectDeptById(Long.valueOf(planQuarter.getPurchaseDeptId())).get("sysDept");
- planQuarter.setPurchaseDeptName(sysDeptResponseVo.getDeptName());
- //预算科目
- for (Map.Entry<String, String> entry : budgetAccountMap.entrySet()) {
- if (!ObjectUtils.isEmpty(planQuarter.getBudgetAccount()) && planQuarter.getBudgetAccount().equals(entry.getValue())) {
- planQuarter.setBudgetAccountStr(entry.getKey());
- break;
- }
- }
- //采购服务站
- for (Map.Entry<String, String> entry : purchaseServicesMap.entrySet()) {
- if (!ObjectUtils.isEmpty(planQuarter.getPurchaseServices()) && planQuarter.getPurchaseServices().equals(entry.getValue())) {
- planQuarter.setPurchaseServicesStr(entry.getKey());
- break;
- }
- }
- //项目审核状态
- for (Map.Entry<String, String> entry : projectStatusMap.entrySet()) {
- if (!ObjectUtils.isEmpty(planQuarter.getProjectStatus()) && planQuarter.getProjectStatus().equals(entry.getValue())) {
- planQuarter.setProjectStatusStr(entry.getKey());
- break;
- }
- }
- //项目类型
- for (Map.Entry<String, String> entry : projectTypesMap.entrySet()) {
- if (!ObjectUtils.isEmpty(planQuarter.getProjectType()) && planQuarter.getProjectType().equals(entry.getValue())) {
- planQuarter.setProjectTypeStr(entry.getKey());
- break;
- }
- }
- //项目属性为value拼接
- if (!ObjectUtils.isEmpty(planQuarter.getProjectAttr())) {
- if (planQuarter.getProjectAttr().length() > 1) {
- StringBuilder builder = new StringBuilder();
- String[] split = planQuarter.getProjectAttr().split(",");
- for (String s : split) {
- for (Map.Entry<String, String> entry : projectAttributes.entrySet()) {
- if (s.equals(entry.getValue())) {
- if (!planQuarter.getProjectAttr().endsWith(s)) {
- builder.append(entry.getKey() + ",");
- } else {
- builder.append(entry.getKey());
- }
- break;
- }
- }
- }
- planQuarter.setProjectAttrName(builder.toString());
- } else {
- for (Map.Entry<String, String> entry : projectAttributes.entrySet()) {
- if (planQuarter.getProjectAttr().equals(entry.getValue())) {
- planQuarter.setProjectAttrName(entry.getKey());
- break;
- }
- }
- }
- }
- //机关业务指导处(科)为id拼接
- String organDivision = planQuarter.getOrganDivision();
- if (!ObjectUtils.isEmpty(organDivision)) {
- int length = organDivision.split(",").length;
- SysDeptOrgan organ = new SysDeptOrgan();
- if (length > 1) {
- StringBuilder builder = new StringBuilder();
- String[] split = organDivision.split(",");
- for (String s : split) {
- organ = sysDeptOrganMapper.selectById(s);
- if (!ObjectUtils.isEmpty(organ)) {
- if (!organDivision.endsWith(s)) {
- builder.append(organ.getOrganName() + ",");
- } else {
- builder.append(organ.getOrganName());
- }
- }
- }
- planQuarter.setOrganDivisionStr(builder.toString());
- } else if (length == 1) {
- organ = sysDeptOrganMapper.selectById(organDivision);
- if (!ObjectUtils.isEmpty(organ)) {
- planQuarter.setOrganDivisionStr(organ.getOrganName());
- }
- }
- }
- //是否可以申请撤销和申请修改
- //需求待填制可以申请,需求建档就不能申请
- PmDemand demand = demandService.selectByPlanId(planQuarter.getPlanPracticalId());
- if (!ObjectUtils.isEmpty(demand) && !demand.getProjectStatus().equals(PmProjectStatus.DEMAND_WAIT_FILL.getCode())) {
- planQuarter.setAppDeleteDo("false");
- planQuarter.setAppUpdateDo("false");
- } else {
- //能否申请撤销
- if (!ObjectUtils.isEmpty(planQuarter.getAppDelete()) && planQuarter.getAppDelete().equals("true")) {
- //申请过的不能再申请
- planQuarter.setAppDeleteDo("false");
- } else if (planQuarter.getProjectStatus().equals("0")) {
- planQuarter.setAppDeleteDo("false");
- } else {
- //提交后可以申请撤销
- planQuarter.setAppDeleteDo("true");
- }
- //能否申请修改
- if (!ObjectUtils.isEmpty(planQuarter.getAppUpdate()) && planQuarter.getAppUpdate().equals("true")) {
- //申请过的不能再申请
- planQuarter.setAppUpdateDo("false");
- } else if (planQuarter.getProjectStatus().equals("0")) {
- planQuarter.setAppUpdateDo("false");
- } else {
- //提交后可以申请撤销
- planQuarter.setAppUpdateDo("true");
- }
- }
- BeanUtils.copyProperties(planQuarter, responseVo);
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
- responseVo.setPlanDemandSubTimeStr(sdf.format(responseVo.getPlanDemandSubTime()));
- responseVo.setPlanPurchaseFinishTimeStr(sdf.format(responseVo.getPlanPurchaseFinishTime()));
- responseVo.setPlanDeliverTimeStr(sdf.format(responseVo.getPlanDeliverTime()));
- //状态在采购需求对接和流废标退回之间的项目可以进行催告---已发函不可再次发函
- responseVo.setSendLetterDo("false");
- if (!ObjectUtils.isEmpty(demand)) {
- if (sendLetterDo(demand.getProjectStatus()) && planQuarter.getSendLetter().equals("0")) {
- responseVo.setSendLetterDo("true");
- }
- }
- try {
- responseVo.setTipsMessage(planQuarterGetTips(thresholdMap, alertTimeMap));
- } catch (ParseException e) {
- e.printStackTrace();
- }
- list.add(responseVo);
- }
- return list;
- }
- //是否可以执行发函
- @Override
- public boolean sendLetterDo(String projectStatus) {
- List<String> ls = new ArrayList<>();
- ls.add(PmProjectStatus.PURCHASE_DEMAND_DOCKING.getCode());
- ls.add(PmProjectStatus.EXPERT_FEEDBACK.getCode());
- ls.add(PmProjectStatus.PROCUREMENT_DOCUMENTS_REVIEW.getCode());
- ls.add(PmProjectStatus.PROCUREMENT_ANNOUNCEMENT.getCode());
- ls.add(PmProjectStatus.PRE_BID_QUERY.getCode());
- ls.add(PmProjectStatus.WAIT_OPEN_BID.getCode());
- ls.add(PmProjectStatus.BID_RESULT_ANNOUNCEMENT.getCode());
- ls.add(PmProjectStatus.WASTE_BID_HANDLE.getCode());
- ls.add(PmProjectStatus.POST_BID_QUERY.getCode());
- ls.add(PmProjectStatus.WASTE_BID_RETURN.getCode());
- return ls.contains(projectStatus);
- }
- @Override
- public List<Integer> idNotDemand() {
- return planQuarterMapper.idNotDemand();
- }
- /**
- * 根据季度计划在各个季度提报时间的阈值进行提示
- *
- * @return
- */
- public String planQuarterGetTips(HashMap<String, String> thresholdMap, HashMap<String, String> alertTimeMap) throws ParseException {
- //提示信息:定义距离结束时间*天内提示
- int alertDay = Integer.parseInt(alertTimeMap.get("计划提报时间"));
- Integer remindTine = 1000 * 60 * 60 * 24 * alertDay;
- String subTips = "";
- //季度提报时间的结束时间阈值
- Date thresholdTime = null;
- SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
- Date date = new Date();
- for (QuarterEnum val : QuarterEnum.values()) {
- if (val.getInfo().contains(date.getMonth() + "")) {
- switch (val.getCode()) {
- case "1":
- thresholdTime = dateFormat.parse(thresholdMap.get("第一季度结束时间"));
- case "2":
- thresholdTime = dateFormat.parse(thresholdMap.get("第二季度结束时间"));
- case "3":
- thresholdTime = dateFormat.parse(thresholdMap.get("第三季度结束时间"));
- case "4":
- thresholdTime = dateFormat.parse(thresholdMap.get("第四季度结束时间"));
- default:
- }
- break;
- }
- }
- double surplus = thresholdTime.getTime() - date.getTime();
- //少于设定时间便提醒
- if (surplus < remindTine && surplus > 0) {
- //剩余天数(向上取整)
- int i = (int) Math.ceil(surplus / 1000 / 60 / 60 / 24);
- if (i > 0) {
- subTips = "距离计划提报时间不足" + i + "天";
- }
- }
- return subTips;
- }
- //是否在提报时间内
- public Boolean isBetweenValue(PlanQuarter planQuarter) {
- //获取年度计划提报时间的阈值
- //获取季度计划各个季度提报时间的阈值
- List<SysDictData> supTime = dictTypeService.selectDictDataByType("sys_quarterly_plan");
- HashMap<String, String> thresholdMap = new LinkedHashMap<>();
- //各个季度提报时间的阈值
- for (SysDictData dictData : supTime) {
- // 季度----阈值
- thresholdMap.put(dictData.getDictLabel(), dictData.getDictValue());
- }
- SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
- Date thresholdTimeStart = null;
- Date thresholdTimeEnd = null;
- Calendar instance = Calendar.getInstance();
- instance.setTime(planQuarter.getPlanDemandSubTime());
- try {
- for (QuarterEnum val : QuarterEnum.values()) {
- if (val.getInfo().contains((instance.get(Calendar.MONTH) + 1) + "")) {
- //System.err.println("MONTH" + (instance.get(Calendar.MONTH) + 1));
- switch (val.getCode()) {
- case "1":
- thresholdTimeStart = dateFormat.parse(thresholdMap.get("第一季度开始时间"));
- thresholdTimeEnd = dateFormat.parse(thresholdMap.get("第一季度结束时间"));
- break;
- case "2":
- thresholdTimeStart = dateFormat.parse(thresholdMap.get("第二季度开始时间"));
- thresholdTimeEnd = dateFormat.parse(thresholdMap.get("第二季度结束时间"));
- break;
- case "3":
- thresholdTimeStart = dateFormat.parse(thresholdMap.get("第三季度开始时间"));
- thresholdTimeEnd = dateFormat.parse(thresholdMap.get("第三季度结束时间"));
- break;
- default:
- thresholdTimeStart = dateFormat.parse(thresholdMap.get("第四季度开始时间"));
- thresholdTimeEnd = dateFormat.parse(thresholdMap.get("第四季度结束时间"));
- }
- break;
- }
- }
- if (!ObjectUtils.isEmpty(thresholdTimeStart) && !ObjectUtils.isEmpty(thresholdTimeEnd)) {
- System.err.println("instance=" + new Date(instance.getTime().getTime()));
- System.err.println("thresholdTimeStart=" + thresholdTimeStart);
- System.err.println("thresholdTimeEnd=" + thresholdTimeEnd);
- System.err.println("instance.before(thresholdTimeStart)=" + instance.before(thresholdTimeStart));
- System.err.println("instance.after(thresholdTimeEnd)=" + instance.after(thresholdTimeEnd));
- Date date = new Date(instance.getTime().getTime());
- if (date.before(thresholdTimeStart) || date.after(thresholdTimeEnd)) {
- return false;
- }
- }
- } catch (ParseException e) {
- e.printStackTrace();
- }
- return true;
- }
- }
|