|
@@ -243,6 +243,64 @@ public class DeptResponsibilityServiceImpl extends ServiceImpl<DeptResponsibilit
|
|
|
@Transactional
|
|
|
@Override
|
|
|
public boolean saveOrUpdate(DeptResponsibility entity) {
|
|
|
+ //获取指定部门的规则
|
|
|
+ List<OrganizationEvaluationRule> list = organizationEvaluationRuleService.listByIsCheck(entity.getOrganizationType(),entity.getCheckCycle(), true, false);
|
|
|
+ if (null == list || list.size() <= 0) {
|
|
|
+ throw new CustomException("不存在单位权重配置");
|
|
|
+ }
|
|
|
+ //获取组织id;
|
|
|
+ List<String> organizationIds = list.stream().map(OrganizationEvaluationRule::getOrganizationId).collect(Collectors.toList());
|
|
|
+
|
|
|
+ StringBuilder responsibilityCode = new StringBuilder();
|
|
|
+ responsibilityCode.append(entity.getOrganizationType()).append("_");
|
|
|
+ responsibilityCode.append(entity.getCheckCycle()).append("_");
|
|
|
+
|
|
|
+ //判断该是否存在目标责任书
|
|
|
+ List<DeptResponsibility> oriList = new ArrayList<>();
|
|
|
+ if ("NDKP".equals(entity.getCheckCycle())) {
|
|
|
+ oriList = list("", entity.getCheckCycle(), entity.getYear(), "");
|
|
|
+ responsibilityCode.append(entity.getYear()).append("_");
|
|
|
+ }
|
|
|
+ if ("JDKP".equals(entity.getCheckCycle())) {
|
|
|
+ Date newDate = DateUtils.toDate(entity.getYear() + "-" + entity.getMonth() + "-01");
|
|
|
+ String season = String.valueOf(DateUtils.getSeason(newDate));//获取季度
|
|
|
+ String month = String.valueOf(Integer.valueOf(entity.getMonth()) * Integer.valueOf(season));//季度考评将
|
|
|
+ oriList = list("", entity.getCheckCycle(), entity.getYear(), month);
|
|
|
+ responsibilityCode.append(entity.getYear()).append("_").append(month).append("_");
|
|
|
+ }
|
|
|
+ if ("YDKP".equals(entity.getCheckCycle())) {
|
|
|
+ oriList = list("", entity.getCheckCycle(), entity.getYear(), entity.getMonth());
|
|
|
+ responsibilityCode.append(entity.getYear()).append("_").append(entity.getMonth()).append("_");
|
|
|
+ }
|
|
|
+ responsibilityCode.append(DateUtils.toDate(new Date()));
|
|
|
+
|
|
|
+ if (null != entity && (null == entity.getId() || "".equals(entity.getId().trim()))) {
|
|
|
+ if (null != oriList && oriList.size() > 0) {
|
|
|
+ throw new CustomException("此单位在该阶段已存在目标责任书");
|
|
|
+ }
|
|
|
+ //保存目标责任书
|
|
|
+ entity.setResponsibilityCode(responsibilityCode.toString());
|
|
|
+ entity.setOrganizationId(organizationIds.toString());//考评组织ID
|
|
|
+ entity.setStage("流程未启动");
|
|
|
+ entity.setCreateTime(new Date());
|
|
|
+ } else {
|
|
|
+ DeptResponsibility update = baseMapper.selectById(entity.getId());
|
|
|
+ if (null != oriList && oriList.size() > 1 && !update.getId().equals(oriList.get(0).getId())) {
|
|
|
+ throw new CustomException("编辑记录未找到");
|
|
|
+ }
|
|
|
+ if (!"流程未启动".equals(update.getStage())) {
|
|
|
+ throw new CustomException("流程已启动不允许修改");
|
|
|
+ }
|
|
|
+ entity.setOrganizationId(organizationIds.toString());//考评组织ID
|
|
|
+ entity.setUpdateTime(new Date());
|
|
|
+ }
|
|
|
+ boolean b = super.saveOrUpdate(entity);
|
|
|
+ return b;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Transactional
|
|
|
+ @Override
|
|
|
+ public boolean saveOrUpdate2(DeptResponsibility entity) {
|
|
|
|
|
|
//获取指定部门的规则
|
|
|
OrganizationEvaluationRule evaluationRule = organizationEvaluationRuleService.getById(entity.getOrganizationEvaluationRuleId());
|
|
@@ -302,10 +360,19 @@ public class DeptResponsibilityServiceImpl extends ServiceImpl<DeptResponsibilit
|
|
|
@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);
|
|
|
+ if (StringUtils.isNotEmpty(organizationId)) {
|
|
|
+ qw.lambda().eq(DeptResponsibility::getOrganizationId, organizationId);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtils.isNotEmpty(checkCycle)) {
|
|
|
+ qw.lambda().eq(DeptResponsibility::getCheckCycle, checkCycle);
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(year)) {
|
|
|
+ qw.lambda().eq(DeptResponsibility::getYear, year);
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(month)) {
|
|
|
+ qw.lambda().in(DeptResponsibility::getMonth, month);
|
|
|
+ }
|
|
|
List<DeptResponsibility> list = baseMapper.selectList(qw);
|
|
|
return list;
|
|
|
}
|