|
@@ -1,5 +1,7 @@
|
|
|
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.entity.SysDept;
|
|
|
import com.ozs.common.core.domain.entity.SysDictData;
|
|
@@ -10,19 +12,20 @@ import com.ozs.common.exception.ServiceException;
|
|
|
import com.ozs.common.utils.StringUtils;
|
|
|
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.system.domain.vo.responseVo.SysDeptResponseVo;
|
|
|
import com.ozs.system.mapper.SysDeptMapper;
|
|
|
+import com.ozs.system.service.ISysDeptService;
|
|
|
import com.ozs.system.service.ISysDictTypeService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.util.ObjectUtils;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.LinkedHashMap;
|
|
|
-import java.util.List;
|
|
|
+import java.util.*;
|
|
|
|
|
|
@Service
|
|
|
public class ProvisionalPlanServiceImpl extends ServiceImpl<ProvisionalPlanMapper, ProvisionalPlan> implements ProvisionalPlanService {
|
|
@@ -33,6 +36,8 @@ public class ProvisionalPlanServiceImpl extends ServiceImpl<ProvisionalPlanMappe
|
|
|
private ISysDictTypeService dictTypeService;
|
|
|
@Autowired
|
|
|
private SysDeptMapper deptMapper;
|
|
|
+ @Autowired
|
|
|
+ private ISysDeptService deptService;
|
|
|
|
|
|
@Override
|
|
|
public int deleteProvisionalPlanById(Integer planYearId) {
|
|
@@ -87,17 +92,10 @@ public class ProvisionalPlanServiceImpl extends ServiceImpl<ProvisionalPlanMappe
|
|
|
ofProvisionalPlan.setIsExcess(isExcessOrNo(ofProvisionalPlan.getProjectType(), ofProvisionalPlan.getEvaluation()));
|
|
|
ofProvisionalPlan.setCreated(String.valueOf(loginUser.getUserId()));
|
|
|
ofProvisionalPlan.setCreateTime(new Date());
|
|
|
+ ofProvisionalPlan.setPlanType("1");
|
|
|
provisionalPlanMapper.insert(ofProvisionalPlan);
|
|
|
successNum++;
|
|
|
successMsg.append("*" + successNum + "、项目 " + ofProvisionalPlan.getProjectName() + " 导入成功!");
|
|
|
- //} else if (isUpdateSupport) {
|
|
|
- // PlanYears years = plan.get(0);
|
|
|
- // BeanValidators.validateWithException(validator, ofYear);
|
|
|
- // years.setCreateTime(new Date());
|
|
|
- // years.setProjectStatus(ProjectStatus.PLANWAITCOMMIT.getCode());
|
|
|
- // planYearsMapper.updateById(years);
|
|
|
- // successNum++;
|
|
|
- // successMsg.append("<br/>" + successNum + "、项目 " + ofYear.getProjectName() + " 更新成功");
|
|
|
} else {
|
|
|
failureNum++;
|
|
|
failureMsg.append("*" + successNum + "、项目 " + ofProvisionalPlan.getProjectName() + " 已存在");
|
|
@@ -118,6 +116,45 @@ public class ProvisionalPlanServiceImpl extends ServiceImpl<ProvisionalPlanMappe
|
|
|
return successMsg.toString();
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public List<ProvisionalPlan> selectProvisionalPlanExport(ProvisionalPlanVo vo) {
|
|
|
+ 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>();
|
|
|
+ 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.getStartTime())) {
|
|
|
+ lw.ge(ProvisionalPlan::getPlanDemandSubTime, vo.getStartTime());
|
|
|
+ }
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+
|
|
|
//判断是否为超额计划
|
|
|
public String isExcessOrNo(String projectType, BigDecimal evaluation) {
|
|
|
BigDecimal threshold = new BigDecimal(0);
|
|
@@ -143,4 +180,62 @@ public class ProvisionalPlanServiceImpl extends ServiceImpl<ProvisionalPlanMappe
|
|
|
return ("0");
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ //字段赋值对应的名称
|
|
|
+ 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(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;
|
|
|
+ }
|
|
|
}
|