|
@@ -2,16 +2,24 @@ package com.ims.eval.service.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+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.DeptResponsibilityMapper;
|
|
|
+import com.ims.eval.entity.EvaluateRule;
|
|
|
+import com.ims.eval.entity.EvaluateRuleInfo;
|
|
|
+import com.ims.eval.entity.OrganizationEvaluationRule;
|
|
|
import com.ims.eval.service.*;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Arrays;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -47,22 +55,76 @@ public class DeptResponsibilityServiceImpl extends ServiceImpl<DeptResponsibilit
|
|
|
*/
|
|
|
private IEvaluateRuleService evaluateRuleService;
|
|
|
|
|
|
-
|
|
|
+ /**
|
|
|
+ * 考评规则明细业务类
|
|
|
+ */
|
|
|
+ private IEvaluateRuleInfoService evaluateRuleInfoService;
|
|
|
|
|
|
|
|
|
@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) {
|
|
|
+
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean generateResponsibility(String orgEvalRuleId, String date) {
|
|
|
+
|
|
|
+ Date newDate;
|
|
|
+ //获取当前时间
|
|
|
+ if (StringUtils.isEmpty(date)) {
|
|
|
+ newDate = DateUtils.getCurrentDate();
|
|
|
+ } else {
|
|
|
+ newDate = DateUtils.toDate(date);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //获取指定部门的规则
|
|
|
+ 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)), "");
|
|
|
+ }
|
|
|
+ if ("JDKP".equals(evaluationRule.getEvaluationCycle())) {
|
|
|
+ oriList = list(evaluationRule.getOrganizationId(), evaluationRule.getEvaluationCycle(), String.valueOf(DateUtils.getYear(newDate)), String.valueOf(DateUtils.getSeason(newDate)));
|
|
|
+ }
|
|
|
+ if ("YDKP".equals(evaluationRule.getEvaluationCycle())) {
|
|
|
+ oriList = list(evaluationRule.getOrganizationId(), evaluationRule.getEvaluationCycle(), String.valueOf(DateUtils.getYear(newDate)), String.valueOf(DateUtils.getYear(newDate)));
|
|
|
+ }
|
|
|
+ if(oriList.size()>0){
|
|
|
+ throw new CustomException("已存在该单位目标责任书");
|
|
|
+ }
|
|
|
+
|
|
|
+ //获取对应的考评规(至少存在一条)
|
|
|
+ List<String> evaluateRuleIds = Arrays.asList(evaluationRule.getEvaluateRuleId().split(","));
|
|
|
+ List<EvaluateRule> evaluateRuleList = evaluateRuleService.listAll(evaluateRuleIds);
|
|
|
+ if(null == evaluateRuleList || evaluateRuleList.size()<=0){
|
|
|
+ throw new CustomException("未获取到配置的规则");
|
|
|
+ }
|
|
|
+
|
|
|
+ //获取考评规则的id
|
|
|
+ List<String> ruleIds = evaluateRuleList.stream().map(EvaluateRule::getId).collect(Collectors.toList());
|
|
|
+ //通过规则id获取对应的规则明细
|
|
|
+ List<EvaluateRuleInfo> ruleInfos = evaluateRuleInfoService.list(ruleIds);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
@Transactional
|
|
|
@Override
|
|
|
public boolean saveOrUpdate(DeptResponsibility entity) {
|
|
|
QueryWrapper<DeptResponsibility> qw = new QueryWrapper();
|
|
|
if (null != entity && (null == entity.getId() || "".equals(entity.getId().trim()))) {
|
|
|
- qw.lambda().eq(DeptResponsibility::getOrganizationId,entity.getOrganizationId());
|
|
|
- qw.lambda().eq(DeptResponsibility::getCheckCycle,entity.getCheckCycle());
|
|
|
- qw.lambda().eq(DeptResponsibility::getYear,entity.getYear());
|
|
|
+ qw.lambda().eq(DeptResponsibility::getOrganizationId, entity.getOrganizationId());
|
|
|
+ qw.lambda().eq(DeptResponsibility::getCheckCycle, entity.getCheckCycle());
|
|
|
+ qw.lambda().eq(DeptResponsibility::getYear, entity.getYear());
|
|
|
List<DeptResponsibility> list = baseMapper.selectList(qw);
|
|
|
if (null != list && list.size() > 0) {
|
|
|
throw new CustomException("此单位在该阶段已存在目标责任书");
|
|
@@ -74,19 +136,19 @@ public class DeptResponsibilityServiceImpl extends ServiceImpl<DeptResponsibilit
|
|
|
}
|
|
|
|
|
|
boolean b = super.saveOrUpdate(entity);
|
|
|
- //判断目标责任书主表新增成功
|
|
|
- if(b){
|
|
|
|
|
|
- //获取当前单位对应的考评规则
|
|
|
- entity.getOrganizationId();
|
|
|
- //周期
|
|
|
- entity.getCheckCycle();
|
|
|
-
|
|
|
-// organizationEvaluationRuleService
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
+ return b;
|
|
|
+ }
|
|
|
|
|
|
- return b ;
|
|
|
+ @Override
|
|
|
+ public List<DeptResponsibility> list(String organizationId, String checkCycle, String year, String month) {
|
|
|
+ QueryWrapper<DeptResponsibility> qw = new QueryWrapper<>();
|
|
|
+ qw.lambda().eq(DeptResponsibility::getOrganizationId, organizationId);
|
|
|
+ qw.lambda().eq(DeptResponsibility::getCheckCycle, checkCycle);
|
|
|
+ qw.lambda().eq(DeptResponsibility::getYear, year);
|
|
|
+ qw.lambda().in(DeptResponsibility::getYear, month);
|
|
|
+ List<DeptResponsibility> list = baseMapper.selectList(qw);
|
|
|
+ return list;
|
|
|
}
|
|
|
+
|
|
|
}
|