|
@@ -1,10 +1,13 @@
|
|
|
package com.ozs.plan.service.impl;
|
|
|
|
|
|
+import com.ozs.common.constant.UserConstants;
|
|
|
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.model.LoginUser;
|
|
|
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.StringUtils;
|
|
|
import com.ozs.common.utils.bean.BeanUtils;
|
|
@@ -13,7 +16,10 @@ import com.ozs.plan.doman.vo.requestVo.PlanYearsStandardVo;
|
|
|
import com.ozs.plan.doman.vo.responseVo.PlanYearsResponseVo;
|
|
|
import com.ozs.plan.mapper.PlanYearsMapper;
|
|
|
import com.ozs.plan.service.PlanYearsService;
|
|
|
+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.impl.SysUserServiceImpl;
|
|
@@ -29,6 +35,7 @@ import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.LinkedHashMap;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* @author buzhanyi
|
|
@@ -45,11 +52,17 @@ public class PlanYearsServiceImpl implements PlanYearsService {
|
|
|
private ISysDictTypeService dictTypeService;
|
|
|
@Autowired
|
|
|
private ISysDeptService deptService;
|
|
|
+ @Autowired
|
|
|
+ SysFileRefMapper sysFileRefMapper;
|
|
|
+ @Autowired
|
|
|
+ private SysDeptMapper deptMapper;
|
|
|
|
|
|
@Override
|
|
|
public List<PlanYears> selectPlanYearsList(PlanYearsStandardVo vo) {
|
|
|
PlanYears ofYears = new PlanYears();
|
|
|
List<PlanYears> planYears = new ArrayList<>();
|
|
|
+ List<PlanYears> planYearsList = new ArrayList<>();
|
|
|
+
|
|
|
try {
|
|
|
BeanUtils.copyProperties(vo, ofYears);
|
|
|
planYears = planYearsMapper.selectPlanYearsList(ofYears);
|
|
@@ -57,10 +70,11 @@ public class PlanYearsServiceImpl implements PlanYearsService {
|
|
|
SysDeptResponseVo sysDeptResponseVo = (SysDeptResponseVo) deptService.selectDeptById(planYear.getPurchaseDeptId()).get("sysDept");
|
|
|
planYear.setPurchaseDeptName(sysDeptResponseVo.getDeptName());
|
|
|
}
|
|
|
+ planYearsList = changeTo(planYears);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
- return planYears;
|
|
|
+ return planYearsList;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -94,8 +108,19 @@ public class PlanYearsServiceImpl implements PlanYearsService {
|
|
|
//判断是否为超额计划
|
|
|
ofYears.setIsExcess(isExcessOrNo(ofYears.getProjectType(), ofYears.getEvaluation()));
|
|
|
ofYears.setProjectStatus(ProjectStatus.PLANWAITCOMMIT.getCode());
|
|
|
+ ofYears.setSendLetter("0");
|
|
|
ofYears.setCreateTime(new Date());
|
|
|
- planYearsMapper.insertPlanYears(ofYears);
|
|
|
+ Long insertId = planYearsMapper.insertPlanYears(ofYears);
|
|
|
+ List<SysFileRef> sysFileRefs = yearsStandardVo.getSysFileRefs();
|
|
|
+ for (SysFileRef ref : sysFileRefs) {
|
|
|
+ ref.setRedId(insertId);
|
|
|
+ ref.setType(SysFileRefEnum.PLAN_YEAR.getType());
|
|
|
+ ref.setCreated(ofYears.getCreated());
|
|
|
+ ref.setCreateTime(new Date());
|
|
|
+ ref.setUpdated(ofYears.getCreated());
|
|
|
+ ref.setUpdateTime(new Date());
|
|
|
+ sysFileRefMapper.insert(ref);
|
|
|
+ }
|
|
|
return AjaxResult.success();
|
|
|
}
|
|
|
|
|
@@ -118,8 +143,9 @@ public class PlanYearsServiceImpl implements PlanYearsService {
|
|
|
if (byId == null) {
|
|
|
return AjaxResult.error("数据查询失败");
|
|
|
}
|
|
|
- BeanUtils.copyProperties(byId, planYearsResponseVo);
|
|
|
- return AjaxResult.success(planYearsResponseVo);
|
|
|
+ ArrayList<PlanYears> years = new ArrayList<>();
|
|
|
+ years.add(byId);
|
|
|
+ return AjaxResult.success(changeTo(years).get(0));
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -135,6 +161,7 @@ public class PlanYearsServiceImpl implements PlanYearsService {
|
|
|
}
|
|
|
ofYears.setIsExcess(isExcessOrNo(ofYears.getProjectType(), ofYears.getEvaluation()));
|
|
|
ofYears.setUpdateTime(new Date());
|
|
|
+ ofYears.setSendLetter("0");
|
|
|
planYearsMapper.updateById(ofYears);
|
|
|
return AjaxResult.success();
|
|
|
}
|
|
@@ -145,41 +172,49 @@ public class PlanYearsServiceImpl implements PlanYearsService {
|
|
|
throw new ServiceException("导入年度计划数据不能为空!");
|
|
|
}
|
|
|
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> 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");
|
|
|
- //deptService.se
|
|
|
+
|
|
|
int successNum = 0;
|
|
|
int failureNum = 0;
|
|
|
StringBuilder successMsg = new StringBuilder();
|
|
|
StringBuilder failureMsg = new StringBuilder();
|
|
|
+ //deptService
|
|
|
for (PlanYears ofYear : planYears) {
|
|
|
try {
|
|
|
//验证项目名称是否重复导入
|
|
|
List<PlanYears> plan = planYearsMapper.countProjectName(ofYear.getProjectName());
|
|
|
-
|
|
|
+ //将录入信息中的值更改为要保存的数据
|
|
|
if (plan.size() == 0) {
|
|
|
- //将录入信息中的值更改为要保存的数据
|
|
|
+ //采购单位
|
|
|
+ SysDept info = deptMapper.checkDeptNameOnlyOne(ofYear.getPurchaseDeptName());
|
|
|
+ if (StringUtils.isNotNull(info)) {
|
|
|
+ ofYear.setPurchaseDeptId(info.getDeptId());
|
|
|
+ }
|
|
|
ofYear.setProjectType(projectTypesMap.get(ofYear.getProjectType()));
|
|
|
ofYear.setProjectStatus(ProjectStatus.PLANWAITCOMMIT.getCode());
|
|
|
ofYear.setPurchaseMode(planPurchaseModesMap.get(ofYear.getPurchaseMode()));
|
|
|
//项目属性是多选字段
|
|
|
- String[] split = ofYear.getProjectAtt().split(",");
|
|
|
StringBuilder builder = new StringBuilder();
|
|
|
- if (split.length > 1) {
|
|
|
+ if (ofYear.getProjectAttr().contains(",")) {
|
|
|
+ String[] split = ofYear.getProjectAttr().split(",");
|
|
|
for (String s : split) {
|
|
|
builder.append(projectAttributes.get(s) + ",");
|
|
|
}
|
|
|
+ } else {
|
|
|
+ builder.append(projectAttributes.get(ofYear.getProjectAttr()));
|
|
|
}
|
|
|
- ofYear.setProjectAtt(builder.toString());
|
|
|
+ ofYear.setProjectAttr(builder.toString());
|
|
|
ofYear.setPurchaseServices(purchaseServices.get(ofYear.getPurchaseServices()));
|
|
|
+ ofYear.setSendLetter("0");
|
|
|
+ ofYear.setIsExcess(isExcessOrNo(ofYear.getProjectType(), ofYear.getEvaluation()));
|
|
|
ofYear.setCreated(String.valueOf(loginUser.getUserId()));
|
|
|
ofYear.setCreateTime(new Date());
|
|
|
- //采购单位
|
|
|
planYearsMapper.insertPlanYears(ofYear);
|
|
|
successNum++;
|
|
|
- successMsg.append("<br/>" + successNum + "、项目 " + ofYear.getProjectName() + " 导入成功");
|
|
|
+ successMsg.append("*" + successNum + "、项目 " + ofYear.getProjectName() + " 导入成功!");
|
|
|
//} else if (isUpdateSupport) {
|
|
|
// PlanYears years = plan.get(0);
|
|
|
// BeanValidators.validateWithException(validator, ofYear);
|
|
@@ -190,17 +225,17 @@ public class PlanYearsServiceImpl implements PlanYearsService {
|
|
|
// successMsg.append("<br/>" + successNum + "、项目 " + ofYear.getProjectName() + " 更新成功");
|
|
|
} else {
|
|
|
failureNum++;
|
|
|
- failureMsg.append("<br/>" + successNum + "、项目 " + ofYear.getProjectName() + " 已存在");
|
|
|
+ failureMsg.append("*" + successNum + "、项目 " + ofYear.getProjectName() + " 已存在");
|
|
|
}
|
|
|
} catch (Exception exc) {
|
|
|
failureNum++;
|
|
|
- String msg = "<br/>" + successNum + "、项目 " + ofYear.getProjectName() + " 导入失败";
|
|
|
+ String msg = "*" + successNum + "、项目 " + ofYear.getProjectName() + " 导入失败";
|
|
|
failureMsg.append(msg + exc.getMessage());
|
|
|
log.error(msg, exc);
|
|
|
}
|
|
|
}
|
|
|
if (failureNum > 0) {
|
|
|
- failureMsg.insert(0, "导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:");
|
|
|
+ failureMsg.insert(0, "导入失败!共 " + failureNum + " 条数据格式不正确:");
|
|
|
throw new ServiceException(failureMsg.toString());
|
|
|
} else {
|
|
|
successMsg.insert(0, "导入成功!共 " + successNum + " 条,数据如下:");
|
|
@@ -243,13 +278,10 @@ public class PlanYearsServiceImpl implements PlanYearsService {
|
|
|
@Override
|
|
|
public AjaxResult reviewTo(PlanYearsStandardVo vo) {
|
|
|
PlanYears ofYears = new PlanYears();
|
|
|
+ BeanUtils.copyProperties(vo, ofYears);
|
|
|
ofYears.setPlanYearId(vo.getPlanYearId());
|
|
|
ofYears.setProjectStatus(ProjectStatus.PLANTOEXAMINE.getCode());
|
|
|
- int review = planYearsMapper.review(ofYears);
|
|
|
- if (review != 1) {
|
|
|
- return AjaxResult.error("项目状态数据异常");
|
|
|
- }
|
|
|
- return AjaxResult.success();
|
|
|
+ return review(vo, ofYears);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -257,6 +289,16 @@ public class PlanYearsServiceImpl implements PlanYearsService {
|
|
|
PlanYears ofYears = new PlanYears();
|
|
|
BeanUtils.copyProperties(vo, ofYears);
|
|
|
ofYears.setProjectStatus(ProjectStatus.PLANTOBACK.getCode());
|
|
|
+ return review(vo, ofYears);
|
|
|
+ }
|
|
|
+
|
|
|
+ private AjaxResult review(PlanYearsStandardVo vo, PlanYears ofYears) {
|
|
|
+ List<SysFileRef> sysFileRefs = vo.getSysFileRefs();
|
|
|
+ for (SysFileRef ref : sysFileRefs) {
|
|
|
+ ref.setRedId(vo.getPlanYearId());
|
|
|
+ ref.setType(SysFileRefEnum.PLAN_YEAR_EXAMINE.getType());
|
|
|
+ sysFileRefMapper.insert(ref);
|
|
|
+ }
|
|
|
int review = planYearsMapper.review(ofYears);
|
|
|
if (review != 1) {
|
|
|
return AjaxResult.error("项目状态数据异常");
|
|
@@ -277,6 +319,32 @@ public class PlanYearsServiceImpl implements PlanYearsService {
|
|
|
return AjaxResult.success();
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public AjaxResult sendLetter(PlanYearsStandardVo yearsStandardVo) {
|
|
|
+ int review = planYearsMapper.sendLetter(yearsStandardVo.getPlanYearId());
|
|
|
+ if (review != 1) {
|
|
|
+ return AjaxResult.error("项目状态数据异常");
|
|
|
+ }
|
|
|
+ return AjaxResult.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public AjaxResult upLoadPlanFile(PlanYearsStandardVo yearsStandardVo) {
|
|
|
+ List<SysFileRef> sysFileRefs = yearsStandardVo.getSysFileRefs();
|
|
|
+ for (SysFileRef ref : sysFileRefs) {
|
|
|
+ ref.setRedId(yearsStandardVo.getPlanYearId());
|
|
|
+ ref.setType(SysFileRefEnum.PLAN_YEAR.getType());
|
|
|
+ sysFileRefMapper.insert(ref);
|
|
|
+ }
|
|
|
+ return AjaxResult.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public AjaxResult downLoadPlanFile(PlanYearsStandardVo yearsStandardVo) {
|
|
|
+
|
|
|
+ return AjaxResult.success();
|
|
|
+ }
|
|
|
+
|
|
|
//判断是否为超额计划
|
|
|
public String isExcessOrNo(String projectType, BigDecimal evaluation) {
|
|
|
BigDecimal threshold = new BigDecimal(0);
|
|
@@ -302,4 +370,57 @@ public class PlanYearsServiceImpl implements PlanYearsService {
|
|
|
return ("0");
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ //字段赋值对应的名称
|
|
|
+ public List<PlanYears> changeTo(List<PlanYears> planYears) {
|
|
|
+
|
|
|
+ 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<PlanYears> list = new ArrayList<PlanYears>();
|
|
|
+ for (PlanYears planYear : planYears) {
|
|
|
+ for (Map.Entry<String, String> entry : projectTypesMap.entrySet()) {
|
|
|
+ if (planYear.getProjectType().equals(entry.getValue())) {
|
|
|
+ planYear.setProjectType(entry.getKey());
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (Map.Entry<String, String> entry : planPurchaseModesMap.entrySet()) {
|
|
|
+ if (planYear.getPurchaseMode().equals(entry.getValue())) {
|
|
|
+ planYear.setPurchaseMode(entry.getKey());
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //项目属性是拼接的
|
|
|
+ if (planYear.getProjectAttr().length() > 2) {
|
|
|
+ String[] split = planYear.getProjectAttr().split(",");
|
|
|
+ for (String s : split) {
|
|
|
+ for (Map.Entry<String, String> entry : projectAttributes.entrySet()) {
|
|
|
+ if (s.equals(entry.getValue())) {
|
|
|
+ planYear.setProjectAttr(entry.getKey());
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ for (Map.Entry<String, String> entry : projectAttributes.entrySet()) {
|
|
|
+ if (planYear.getProjectAttr().equals(entry.getValue())) {
|
|
|
+ planYear.setProjectAttr(entry.getKey());
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (Map.Entry<String, String> entry : purchaseServices.entrySet()) {
|
|
|
+ if (planYear.getPurchaseServices().equals(entry.getValue())) {
|
|
|
+ planYear.setPurchaseServices(entry.getKey());
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ list.add(planYear);
|
|
|
+ }
|
|
|
+ return list;
|
|
|
+ }
|
|
|
}
|