|
@@ -0,0 +1,74 @@
|
|
|
+package org.springblade.control.service.impl;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import lombok.AllArgsConstructor;
|
|
|
+import org.springblade.common.utils.SnowFlakeUtil;
|
|
|
+import org.springblade.control.dto.ControlProjectInfoDTO;
|
|
|
+import org.springblade.control.entity.DepartmentMonthPlan;
|
|
|
+import org.springblade.control.entity.DictInfo;
|
|
|
+import org.springblade.control.entity.ProjectProcess;
|
|
|
+import org.springblade.control.mapper.DepartmentMonthPlanMapper;
|
|
|
+import org.springblade.control.mapper.ProjectProcessMapper;
|
|
|
+import org.springblade.control.service.IDepartmentMonthPlanService;
|
|
|
+import org.springblade.control.service.IProjectCostBudgetService;
|
|
|
+import org.springblade.control.service.IProjectProcessService;
|
|
|
+import org.springblade.control.vo.ProjectCostBudgetVO;
|
|
|
+import org.springblade.control.vo.ProjectProcessVO;
|
|
|
+import org.springblade.core.log.exception.ServiceException;
|
|
|
+import org.springblade.core.mp.base.BaseServiceImpl;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.time.LocalDate;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @Param
|
|
|
+ * @Author wangwl
|
|
|
+ * @Date 2023/5/12 13:41
|
|
|
+ **/
|
|
|
+@Service
|
|
|
+@AllArgsConstructor
|
|
|
+public class DepartmentMonthPlanServiceImpl extends BaseServiceImpl<DepartmentMonthPlanMapper, DepartmentMonthPlan> implements IDepartmentMonthPlanService {
|
|
|
+
|
|
|
+ private final IProjectCostBudgetService budgetService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 新增部门月计划
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<ProjectCostBudgetVO> addDepartmentPlan(DepartmentMonthPlan plan) {
|
|
|
+ //判断数据库是否存在当前部门当前月数据
|
|
|
+ DepartmentMonthPlan one = this.getOne(new LambdaQueryWrapper<DepartmentMonthPlan>()
|
|
|
+ .eq(DepartmentMonthPlan::getDepartmentType, plan.getDepartmentType())
|
|
|
+ .eq(DepartmentMonthPlan::getPlanDate, plan.getPlanDate()));
|
|
|
+ if (one != null){
|
|
|
+ throw new ServiceException("新增失败,该部门该月份已存在计划");
|
|
|
+ }
|
|
|
+ //获取部门名称
|
|
|
+ String departmentName = baseMapper.getDepartmentName(plan.getDepartmentType());
|
|
|
+ //新增部门月计划,并且设置名称和起止日期,制定人
|
|
|
+ String planDate = plan.getPlanDate();
|
|
|
+ String[] date = planDate.split("-");
|
|
|
+ plan.setPlanName(date[0]+"年"+date[1]+"月"+departmentName+"预算计划");
|
|
|
+ this.save(plan);
|
|
|
+ //查询出部门当月的项目计划,返回
|
|
|
+ List<ProjectCostBudgetVO> voList = new ArrayList<>();
|
|
|
+ if (plan.getDepartmentType() != 5){
|
|
|
+ voList = budgetService.getDepartmentPlan(plan.getDepartmentType(),planDate);
|
|
|
+ }else {
|
|
|
+ voList.addAll(budgetService.getDepartmentPlan(5,planDate));
|
|
|
+ voList.addAll(budgetService.getDepartmentPlan(6,planDate));
|
|
|
+ }
|
|
|
+ return voList;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取部门列表,只要前5个
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<DictInfo> getDepartmentDict() {
|
|
|
+ return baseMapper.getDepartmentDict();
|
|
|
+ }
|
|
|
+}
|