|
@@ -2,19 +2,21 @@ package com.ims.eval.service.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.ims.common.utils.DateUtils;
|
|
|
import com.ims.common.utils.StringUtils;
|
|
|
import com.ims.eval.config.CustomException;
|
|
|
-import com.ims.eval.entity.DeptResponsibility;
|
|
|
+import com.ims.eval.dao.ResponsibilityIndicatorInfoMapper;
|
|
|
+import com.ims.eval.entity.*;
|
|
|
import com.ims.eval.dao.DeptResponsibilityMapper;
|
|
|
-import com.ims.eval.entity.EvaluateRule;
|
|
|
-import com.ims.eval.entity.EvaluateRuleInfo;
|
|
|
-import com.ims.eval.entity.OrganizationEvaluationRule;
|
|
|
+import com.ims.eval.entity.dto.response.IndicatorResDTO;
|
|
|
import com.ims.eval.service.*;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
+import javax.annotation.Resource;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Arrays;
|
|
|
import java.util.Date;
|
|
@@ -36,41 +38,101 @@ public class DeptResponsibilityServiceImpl extends ServiceImpl<DeptResponsibilit
|
|
|
/**
|
|
|
* 指标主业务类
|
|
|
*/
|
|
|
+ @Autowired
|
|
|
private IIndicatorService iIndicatorService;
|
|
|
|
|
|
/**
|
|
|
* 指标子业务类
|
|
|
*/
|
|
|
+ @Autowired
|
|
|
private IIndicatorDictionaryService indicatorDictionaryService;
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 单位/部门考评配置业务类
|
|
|
*/
|
|
|
-
|
|
|
+ @Autowired
|
|
|
private IOrganizationEvaluationRuleService organizationEvaluationRuleService;
|
|
|
|
|
|
/**
|
|
|
* 考评规则业务类
|
|
|
*/
|
|
|
+ @Autowired
|
|
|
private IEvaluateRuleService evaluateRuleService;
|
|
|
|
|
|
/**
|
|
|
* 考评规则明细业务类
|
|
|
*/
|
|
|
+ @Autowired
|
|
|
private IEvaluateRuleInfoService evaluateRuleInfoService;
|
|
|
|
|
|
|
|
|
+ @Resource
|
|
|
+ private ResponsibilityIndicatorInfoMapper responsibilityIndicatorInfoMapper;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private IResponsibilityIndicatorInfoService responsibilityIndicatorInfoService;
|
|
|
+
|
|
|
@Override
|
|
|
- public IPage<DeptResponsibility> list(Integer pageNum, Integer pageSize, String id, String cycleUnit, String checkCycle, String beginDate, String endDate, String binStage, String stage, String createBy, String year, String month) {
|
|
|
+ public IPage<DeptResponsibility> list(Integer pageNum, Integer pageSize, String id, String cycleUnit, String checkCycle, String beginDate, String endDate, String stage, String createBy, String year, String month) {
|
|
|
+
|
|
|
+ QueryWrapper<DeptResponsibility> qw = new QueryWrapper<>();
|
|
|
+ if (null == pageNum || null == pageSize) {
|
|
|
+ throw new CustomException("分页参数为空");
|
|
|
+ }
|
|
|
+ //构造分页构造器
|
|
|
+ Page<DeptResponsibility> page = new Page<>(pageNum, pageSize);
|
|
|
+
|
|
|
+ if (StringUtils.isNotEmpty(id)) {
|
|
|
+ qw.lambda().eq(DeptResponsibility::getId, id);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtils.isNotEmpty(cycleUnit)) {
|
|
|
+ qw.lambda().like(DeptResponsibility::getCycleUnit, cycleUnit);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtils.isNotEmpty(checkCycle)) {
|
|
|
+ qw.lambda().like(DeptResponsibility::getCheckCycle, checkCycle);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtils.isNotEmpty(beginDate) && StringUtils.isNotEmpty(endDate)) {
|
|
|
+ qw.lambda().ge(DeptResponsibility::getBeginDate, beginDate);
|
|
|
+ qw.lambda().le(DeptResponsibility::getEndDate, endDate);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtils.isNotEmpty(stage)) {
|
|
|
+ qw.lambda().eq(DeptResponsibility::getStage, stage);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtils.isNotEmpty(createBy)) {
|
|
|
+ qw.lambda().eq(DeptResponsibility::getCreateBy, createBy);
|
|
|
+ }
|
|
|
|
|
|
- return null;
|
|
|
+ if (StringUtils.isNotEmpty(createBy)) {
|
|
|
+ qw.lambda().eq(DeptResponsibility::getCreateBy, createBy);
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(year)) {
|
|
|
+ qw.lambda().eq(DeptResponsibility::getYear, year);
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(month)) {
|
|
|
+ qw.lambda().eq(DeptResponsibility::getMonth, month);
|
|
|
+ }
|
|
|
+
|
|
|
+ qw.lambda().orderByDesc(DeptResponsibility::getCreateTime);
|
|
|
+
|
|
|
+ IPage<DeptResponsibility> list = baseMapper.selectPage(page, qw);
|
|
|
+ return list;
|
|
|
}
|
|
|
|
|
|
|
|
|
@Override
|
|
|
public boolean generateResponsibility(String orgEvalRuleId, String date) {
|
|
|
|
|
|
+ //单位目标责任书
|
|
|
+ DeptResponsibility responsibility = new DeptResponsibility();
|
|
|
+ //责任书指标详情记录集合
|
|
|
+ //List<ResponsibilityIndicatorInfo> indicatorInfolist = new ArrayList<>();
|
|
|
+
|
|
|
Date newDate;
|
|
|
//获取当前时间
|
|
|
if (StringUtils.isEmpty(date)) {
|
|
@@ -79,42 +141,85 @@ public class DeptResponsibilityServiceImpl extends ServiceImpl<DeptResponsibilit
|
|
|
newDate = DateUtils.toDate(date);
|
|
|
}
|
|
|
|
|
|
+ String year = String.valueOf(DateUtils.getYear(newDate));//获取年份
|
|
|
+ String season = String.valueOf(DateUtils.getSeason(newDate));//获取季度
|
|
|
+ String month = String.valueOf(DateUtils.getMonth(newDate));//获取月份
|
|
|
|
|
|
//获取指定部门的规则
|
|
|
OrganizationEvaluationRule evaluationRule = organizationEvaluationRuleService.getById(orgEvalRuleId);
|
|
|
if (null == evaluationRule) {
|
|
|
throw new CustomException("不存在此单位权重配置");
|
|
|
}
|
|
|
+
|
|
|
//判断该是否存在目标责任书
|
|
|
List<DeptResponsibility> oriList = new ArrayList<>();
|
|
|
if ("NDKP".equals(evaluationRule.getEvaluationCycle())) {
|
|
|
- oriList = list(evaluationRule.getOrganizationId(), evaluationRule.getEvaluationCycle(), String.valueOf(DateUtils.getYear(newDate)), "");
|
|
|
+ oriList = list(evaluationRule.getOrganizationId(), evaluationRule.getEvaluationCycle(), year, "");
|
|
|
}
|
|
|
if ("JDKP".equals(evaluationRule.getEvaluationCycle())) {
|
|
|
- oriList = list(evaluationRule.getOrganizationId(), evaluationRule.getEvaluationCycle(), String.valueOf(DateUtils.getYear(newDate)), String.valueOf(DateUtils.getSeason(newDate)));
|
|
|
+ month = String.valueOf(Integer.valueOf(month) * Integer.valueOf(season));//季度考评将
|
|
|
+ oriList = list(evaluationRule.getOrganizationId(), evaluationRule.getEvaluationCycle(), year, month);
|
|
|
}
|
|
|
if ("YDKP".equals(evaluationRule.getEvaluationCycle())) {
|
|
|
- oriList = list(evaluationRule.getOrganizationId(), evaluationRule.getEvaluationCycle(), String.valueOf(DateUtils.getYear(newDate)), String.valueOf(DateUtils.getYear(newDate)));
|
|
|
+ oriList = list(evaluationRule.getOrganizationId(), evaluationRule.getEvaluationCycle(), year, month);
|
|
|
}
|
|
|
- if(oriList.size()>0){
|
|
|
+ if (oriList.size() > 0) {
|
|
|
throw new CustomException("已存在该单位目标责任书");
|
|
|
}
|
|
|
|
|
|
+ //保存目标责任书
|
|
|
+ responsibility.setOrganizationId(evaluationRule.getOrganizationId());//考评组织ID
|
|
|
+ responsibility.setOrganizationName(evaluationRule.getOrganizationName());//考评组织名称
|
|
|
+ responsibility.setCheckCycle(evaluationRule.getEvaluationCycle());//考评周期
|
|
|
+ responsibility.setYear(year);//年份
|
|
|
+ responsibility.setMonth(month);//月份
|
|
|
+ responsibility.setOrganizationEvaluationRuleId(evaluationRule.getId());//考评规则id
|
|
|
+ //responsibility.setBeginDate(null);
|
|
|
+ //responsibility.setEndDate(null);
|
|
|
+ responsibility.setStage("流程未启动");
|
|
|
+ responsibility.setCreateTime(new Date());
|
|
|
+ //responsibility.setCreateBy("");
|
|
|
+
|
|
|
+ boolean b = super.saveOrUpdate(responsibility);
|
|
|
+ if (!b) {
|
|
|
+ throw new CustomException("保存目标责任书失败");
|
|
|
+ }
|
|
|
+
|
|
|
//获取对应的考评规(至少存在一条)
|
|
|
List<String> evaluateRuleIds = Arrays.asList(evaluationRule.getEvaluateRuleId().split(","));
|
|
|
List<EvaluateRule> evaluateRuleList = evaluateRuleService.listAll(evaluateRuleIds);
|
|
|
- if(null == evaluateRuleList || evaluateRuleList.size()<=0){
|
|
|
+ if (null == evaluateRuleList || evaluateRuleList.size() <= 0) {
|
|
|
throw new CustomException("未获取到配置的规则");
|
|
|
}
|
|
|
-
|
|
|
//获取考评规则的id
|
|
|
- List<String> ruleIds = evaluateRuleList.stream().map(EvaluateRule::getId).collect(Collectors.toList());
|
|
|
+ List<String> ruleIds = evaluateRuleList.stream().map(EvaluateRule::getId).collect(Collectors.toList());
|
|
|
//通过规则id获取对应的规则明细
|
|
|
- List<EvaluateRuleInfo> ruleInfos = evaluateRuleInfoService.list(ruleIds);
|
|
|
-
|
|
|
+ List<EvaluateRuleInfo> ruleInfos = evaluateRuleInfoService.list(ruleIds);
|
|
|
+ if (null == ruleInfos || ruleInfos.size() <= 0) {
|
|
|
+ throw new CustomException("规则明细配置为空");
|
|
|
+ }
|
|
|
+ //获取考评规则中的指标id
|
|
|
+ List<String> indicatorIds = ruleInfos.stream().map(EvaluateRuleInfo::getIndicatorId).collect(Collectors.toList());
|
|
|
+ //通过指标id获取指标明细项
|
|
|
+ List<IndicatorResDTO> resDTOS = iIndicatorService.listByIds(indicatorIds);
|
|
|
+ if (null == resDTOS || resDTOS.size() <= 0) {
|
|
|
+ throw new CustomException("指标规则明细项为空");
|
|
|
+ }
|
|
|
|
|
|
|
|
|
- return false;
|
|
|
+ resDTOS.stream().forEach(r -> {
|
|
|
+ ResponsibilityIndicatorInfo info = new ResponsibilityIndicatorInfo();
|
|
|
+ info.setDeptResponsibilityId(responsibility.getId());
|
|
|
+ info.setIndicatorId(r.getId());
|
|
|
+ info.setIndicatorDictionaryId(r.getIndicatorDictionaryID());
|
|
|
+ info.setOptionCode(r.getOptionCode());
|
|
|
+ info.setIsQuantified(r.getIsQuantified());
|
|
|
+ boolean b2 = responsibilityIndicatorInfoService.saveOrUpdate(info);
|
|
|
+ if (!b2) {
|
|
|
+ throw new CustomException("初始化目标责任书明细失败");
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
@Transactional
|