|
@@ -12,6 +12,8 @@ import org.apache.poi.ss.usermodel.*;
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
import org.springblade.core.log.exception.ServiceException;
|
|
|
import org.springblade.core.mp.base.BaseServiceImpl;
|
|
|
+import org.springblade.core.redis.cache.BladeRedis;
|
|
|
+import org.springblade.core.secure.utils.AuthUtil;
|
|
|
import org.springblade.core.tool.api.R;
|
|
|
import org.springblade.core.tool.utils.Func;
|
|
|
import org.springblade.modules.project.mapper.ProjectInfoMapper;
|
|
@@ -61,6 +63,8 @@ public class ProjectInfoServiceImpl extends BaseServiceImpl<ProjectInfoMapper, P
|
|
|
|
|
|
private final IDictBizService dictBizService;
|
|
|
|
|
|
+ private final BladeRedis bladeRedis;
|
|
|
+
|
|
|
@Override
|
|
|
@Transactional
|
|
|
public Long add(ProjectInfoDTO dto) {
|
|
@@ -210,7 +214,7 @@ public class ProjectInfoServiceImpl extends BaseServiceImpl<ProjectInfoMapper, P
|
|
|
if (plan.getIsFillPlan() == 1){
|
|
|
BigDecimal invest = BigDecimal.ZERO;
|
|
|
BigDecimal investFinish = BigDecimal.ZERO;
|
|
|
- //校验一月已有投资,则不能删除或改为0
|
|
|
+ //校验一季度已有投资,则不能删除或改为0
|
|
|
if (plan.getOneInvest() != null){
|
|
|
invest = invest.add(plan.getOneInvest());
|
|
|
}
|
|
@@ -224,7 +228,7 @@ public class ProjectInfoServiceImpl extends BaseServiceImpl<ProjectInfoMapper, P
|
|
|
plan.setOneInvestRatio(plan.getOneInvestFinish().divide(plan.getOneInvestFinish(),4, RoundingMode.DOWN).multiply(new BigDecimal(100)).setScale(2));
|
|
|
}
|
|
|
|
|
|
- //校验二月已有投资,则不能删除或改为0
|
|
|
+ //校验二季度已有投资,则不能删除或改为0
|
|
|
if (plan.getTwoInvest() != null){
|
|
|
invest = invest.add(plan.getTwoInvest());
|
|
|
}
|
|
@@ -239,7 +243,7 @@ public class ProjectInfoServiceImpl extends BaseServiceImpl<ProjectInfoMapper, P
|
|
|
plan.setTwoAggregateRatio(investFinish.divide(invest,4, RoundingMode.DOWN).multiply(new BigDecimal(100)).setScale(2));
|
|
|
}
|
|
|
|
|
|
- //校验三月已有投资,则不能删除或改为0
|
|
|
+ //校验三季度已有投资,则不能删除或改为0
|
|
|
if (plan.getThreeInvestFinish() != null && (plan.getThreeInvest() == null || plan.getThreeInvest().equals(BigDecimal.ZERO))){
|
|
|
throw new ServiceException(dto.getName() +"的"+plan.getPlanYear()+"年三季度已有投资金额,不能修改为0");
|
|
|
}
|
|
@@ -248,7 +252,7 @@ public class ProjectInfoServiceImpl extends BaseServiceImpl<ProjectInfoMapper, P
|
|
|
plan.setThreeAggregateRatio(investFinish.divide(invest,4, RoundingMode.DOWN).multiply(new BigDecimal(100)).setScale(2));
|
|
|
}
|
|
|
|
|
|
- //校验四月已有投资,则不能删除或改为0
|
|
|
+ //校验四季度已有投资,则不能删除或改为0
|
|
|
if (plan.getFourInvestFinish() != null && (plan.getFourInvest() == null || plan.getFourInvest().equals(BigDecimal.ZERO))){
|
|
|
throw new ServiceException(dto.getName() +"的"+plan.getPlanYear()+"年四季度已有投资金额,不能修改为0");
|
|
|
}
|
|
@@ -258,7 +262,7 @@ public class ProjectInfoServiceImpl extends BaseServiceImpl<ProjectInfoMapper, P
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- investPlanService.updateBatchById(list);
|
|
|
+ investPlanService.saveOrUpdateBatch(list);
|
|
|
|
|
|
}
|
|
|
|
|
@@ -1191,8 +1195,11 @@ public class ProjectInfoServiceImpl extends BaseServiceImpl<ProjectInfoMapper, P
|
|
|
dto.setDutyUnit(project.getDutyUnit());
|
|
|
dto.setIsPilotPlan(project.getIsPilotPlan());
|
|
|
//修改指定年的计划信息
|
|
|
+ Boolean isExist = false;
|
|
|
for (ProjectInvestPlan plan : dto.getList()) {
|
|
|
if (plan.getPlanYear().equals(project.getPlanYear())){
|
|
|
+ isExist = true;
|
|
|
+ plan.setProjectId(project.getProjectId());
|
|
|
plan.setYearlyInvest(project.getYearlyInvest());
|
|
|
plan.setOneInvest(project.getOneInvest());
|
|
|
plan.setTwoInvest(project.getTwoInvest());
|
|
@@ -1209,6 +1216,28 @@ public class ProjectInfoServiceImpl extends BaseServiceImpl<ProjectInfoMapper, P
|
|
|
plan.setPhone(project.getPhone());
|
|
|
}
|
|
|
}
|
|
|
+ //如果当前年计划不存在,则创建当前年计划
|
|
|
+ if (!isExist){
|
|
|
+ ProjectInvestPlan plan = new ProjectInvestPlan();
|
|
|
+ plan.setProjectId(project.getProjectId());
|
|
|
+ plan.setPlanYear(project.getPlanYear());
|
|
|
+ plan.setYearlyInvest(project.getYearlyInvest());
|
|
|
+ plan.setOneInvest(project.getOneInvest());
|
|
|
+ plan.setTwoInvest(project.getTwoInvest());
|
|
|
+ plan.setThreeInvest(project.getThreeInvest());
|
|
|
+ plan.setFourInvest(project.getFourInvest());
|
|
|
+ plan.setYearlyTarget(project.getYearlyTarget());
|
|
|
+ plan.setOnePlan(project.getOnePlan());
|
|
|
+ plan.setTwoPlan(project.getTwoPlan());
|
|
|
+ plan.setThreePlan(project.getThreePlan());
|
|
|
+ plan.setFourPlan(project.getFourPlan());
|
|
|
+ plan.setQuestionable(project.getQuestionable());
|
|
|
+ plan.setWorkAdvise(project.getWorkAdvise());
|
|
|
+ plan.setLinkman(project.getLinkman());
|
|
|
+ plan.setPhone(project.getPhone());
|
|
|
+ plan.setIsFillPlan(0);
|
|
|
+ dto.getList().add(plan);
|
|
|
+ }
|
|
|
//调用项目修改接口修改
|
|
|
this.update2(dto);
|
|
|
}else {
|
|
@@ -1241,6 +1270,26 @@ public class ProjectInfoServiceImpl extends BaseServiceImpl<ProjectInfoMapper, P
|
|
|
}
|
|
|
plans.add(plan);
|
|
|
}
|
|
|
+ //计划年如果不在开工年完工年之间,单独放入
|
|
|
+ if (project.getPlanYear() < project.getStartYear() || project.getPlanYear() > project.getEndYear()){
|
|
|
+ ProjectInvestPlan plan = new ProjectInvestPlan();
|
|
|
+ plan.setPlanYear(project.getPlanYear());
|
|
|
+ plan.setYearlyInvest(project.getYearlyInvest());
|
|
|
+ plan.setOneInvest(project.getOneInvest());
|
|
|
+ plan.setTwoInvest(project.getTwoInvest());
|
|
|
+ plan.setThreeInvest(project.getThreeInvest());
|
|
|
+ plan.setFourInvest(project.getFourInvest());
|
|
|
+ plan.setYearlyTarget(project.getYearlyTarget());
|
|
|
+ plan.setOnePlan(project.getOnePlan());
|
|
|
+ plan.setTwoPlan(project.getTwoPlan());
|
|
|
+ plan.setThreePlan(project.getThreePlan());
|
|
|
+ plan.setFourPlan(project.getFourPlan());
|
|
|
+ plan.setQuestionable(project.getQuestionable());
|
|
|
+ plan.setWorkAdvise(project.getWorkAdvise());
|
|
|
+ plan.setLinkman(project.getLinkman());
|
|
|
+ plan.setPhone(project.getPhone());
|
|
|
+ plans.add(plan);
|
|
|
+ }
|
|
|
infoDTO.setList(plans);
|
|
|
project.setProjectId(this.add(infoDTO));
|
|
|
}
|
|
@@ -1264,6 +1313,11 @@ public class ProjectInfoServiceImpl extends BaseServiceImpl<ProjectInfoMapper, P
|
|
|
return R.success("导入成功:新增"+add+"个项目,修改"+update+"个项目");
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 按照Map解析出指定格式的集合
|
|
|
+ * @param file
|
|
|
+ * @return
|
|
|
+ */
|
|
|
private List<ProjectImportExcel> parseExcelFile(MultipartFile file) {
|
|
|
//获取项目类型,项目进展类型,并转换为map
|
|
|
Map<String, Integer> typeMap = dictBizService.getList("projectType").stream().collect(Collectors.toMap(l -> l.getDictValue(), l -> Integer.valueOf(l.getDictKey())));
|
|
@@ -1355,8 +1409,10 @@ public class ProjectInfoServiceImpl extends BaseServiceImpl<ProjectInfoMapper, P
|
|
|
//校验年是否被改变
|
|
|
ProjectImportExcel pro = new ProjectImportExcel();
|
|
|
String name = row.getCell(1, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK).getStringCellValue();
|
|
|
-
|
|
|
try {
|
|
|
+ if (StringUtils.isBlank(name)){
|
|
|
+ throw new ServiceException("项目名称不能为空");
|
|
|
+ }
|
|
|
if (projectStage == 0){
|
|
|
throw new ServiceException("未获取到项目进程");
|
|
|
}
|
|
@@ -1375,16 +1431,16 @@ public class ProjectInfoServiceImpl extends BaseServiceImpl<ProjectInfoMapper, P
|
|
|
}
|
|
|
//todo 如果后面可以导入不是标题年的项目,则修改先判断是否存在计划,存在计划才校验
|
|
|
//校验标题年份是否在开工和完工之间
|
|
|
- if (year < startYear || year > endYear){
|
|
|
- throw new ServiceException("标题年份不在开工和完工年之间");
|
|
|
- }
|
|
|
+// if (year < startYear || year > endYear){
|
|
|
+// throw new ServiceException("标题年份不在开工和完工年之间");
|
|
|
+// }
|
|
|
ProjectInfo info = projectMap.get(name);
|
|
|
if (info != null){
|
|
|
pro.setProjectId(info.getId());
|
|
|
pro.setIsExist(true);
|
|
|
- if (!startYear.equals(info.getStartYear()) || !endYear.equals(info.getEndYear())){
|
|
|
- throw new ServiceException("项目已存在,开工年完工年和已有数据不同");
|
|
|
- }
|
|
|
+// if (!startYear.equals(info.getStartYear()) || !endYear.equals(info.getEndYear())){
|
|
|
+// throw new ServiceException("项目已存在,开工年完工年和已有数据不同");
|
|
|
+// }
|
|
|
}else {
|
|
|
pro.setIsExist(false);
|
|
|
}
|
|
@@ -1456,7 +1512,11 @@ public class ProjectInfoServiceImpl extends BaseServiceImpl<ProjectInfoMapper, P
|
|
|
}
|
|
|
list.add(pro);
|
|
|
}catch (Exception e){
|
|
|
- throw new ServiceException("项目:"+name+" 解析失败,原因:"+e.getMessage());
|
|
|
+ if (e.getMessage().contains("decimal")){
|
|
|
+ throw new ServiceException("项目:" + name + " 解析失败,原因:" + "数字转换异常,请检查数字格式,和不要设置公式");
|
|
|
+ }else {
|
|
|
+ throw new ServiceException("项目:" + name + " 解析失败,原因:" + e.getMessage());
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|