Преглед изворни кода

目标责任书明细修改

wangchangsheng пре 2 година
родитељ
комит
06746e9ab3

+ 32 - 0
ims-common/src/main/java/com/ims/common/utils/StringUtils.java

@@ -449,4 +449,36 @@ public class StringUtils{
 	public static boolean notEmp(Object obj) {
 		return !empty(obj);
 	}
+
+
+	/**
+	 * 给字符串的左补0或右补0
+	 * @param str  要处理的字符串
+	 * @param length 补0后字符串总长度
+	 * @param type  l-左补0  r-右补0
+	 * @return
+	 */
+	public static String addZeroForStr(String str, int length,String  type) {
+		int strLen = str.length();
+		if (strLen < length) {
+			while (strLen < length) {
+				StringBuffer sb = new StringBuffer();
+				if("l".equals(type)){
+					// 左补0
+					sb.append("0").append(str);
+				}else if("r".equals(type)){
+					//右补0
+					sb.append(str).append("0");
+				}
+				str = sb.toString();
+				strLen = str.length();
+			}
+		}
+		return str;
+	}
+
+
+
+
+
 }

+ 0 - 1
ims-service/ims-eval/src/main/java/com/ims/eval/service/IDeptResponsibilityService.java

@@ -23,5 +23,4 @@ public interface IDeptResponsibilityService extends IService<DeptResponsibility>
 
 	boolean generateResponsibility(String orgEvalRuleId);
 
-	boolean saveOrUpdate2(DeptResponsibility entity);
 }

+ 67 - 159
ims-service/ims-eval/src/main/java/com/ims/eval/service/impl/DeptResponsibilityServiceImpl.java

@@ -74,9 +74,9 @@ public class DeptResponsibilityServiceImpl extends ServiceImpl<DeptResponsibilit
 	private IResponsibilityIndicatorInfoService responsibilityIndicatorInfoService;
 
 	@Override
-	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) {
+	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<>();
+		QueryWrapper<DeptResponsibility> qw = new QueryWrapper<>();
 		if (null == pageNum || null == pageSize) {
 			throw new CustomException("分页参数为空");
 		}
@@ -129,114 +129,68 @@ public class DeptResponsibilityServiceImpl extends ServiceImpl<DeptResponsibilit
 	@Override
 	public boolean generateResponsibility(String id) {
 
-		//单位目标责任书
-//		DeptResponsibility responsibility = new DeptResponsibility();
-		//责任书指标详情记录集合
-		//List<ResponsibilityIndicatorInfo> indicatorInfolist = new ArrayList<>();
-
-//		Date newDate;
-//		//获取当前时间
-//		if (StringUtils.isEmpty(date)) {
-//			newDate = DateUtils.getCurrentDate();
-//		} else {
-//			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));//获取月份
-
-		DeptResponsibility oriResponsibility =  baseMapper.selectById(id);
+		DeptResponsibility oriResponsibility = baseMapper.selectById(id);
 		if (null == oriResponsibility) {
 			throw new CustomException("此目标责任书不存在");
 		}
 
-		QueryWrapper<ResponsibilityIndicatorInfo> infoqw =  new QueryWrapper<>();
-		infoqw.lambda().eq(ResponsibilityIndicatorInfo::getDeptResponsibilityId,id);
+		QueryWrapper<ResponsibilityIndicatorInfo> infoqw = new QueryWrapper<>();
+		infoqw.lambda().eq(ResponsibilityIndicatorInfo::getDeptResponsibilityId, id);
 		int infcount = responsibilityIndicatorInfoService.count(infoqw);
-		if (infcount>0) {
-			throw new CustomException("编号"+oriResponsibility.getResponsibilityCode()+"的责任书已启动;不允许重复操作");
+		if (infcount > 0) {
+			throw new CustomException("编号" + oriResponsibility.getResponsibilityCode() + "的责任书已启动;不允许重复操作");
 		}
 
 		oriResponsibility.setStage("流程启动");
 		baseMapper.updateById(oriResponsibility);
 
+		List<String> evaluationRuleIds = Arrays.asList(oriResponsibility.getOrganizationEvaluationRuleId().split(","));
 
-		//获取指定部门的规则
-		OrganizationEvaluationRule evaluationRule = organizationEvaluationRuleService.getById(oriResponsibility.getOrganizationEvaluationRuleId());
-		if (null == evaluationRule) {
-			throw new CustomException("不存在此单位权重配置");
-		}
-//
-//		//判断该是否存在目标责任书
-//		List<DeptResponsibility> oriList = new ArrayList<>();
-//		if ("NDKP".equals(evaluationRule.getEvaluationCycle())) {
-//			oriList = list(evaluationRule.getOrganizationId(), evaluationRule.getEvaluationCycle(), year, "");
-//		}
-//		if ("JDKP".equals(evaluationRule.getEvaluationCycle())) {
-//			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(), year, month);
-//		}
-//		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) {
-			throw new CustomException("未获取到配置的规则");
-		}
-		//获取考评规则的id
-		List<String> ruleIds = evaluateRuleList.stream().map(EvaluateRule::getId).collect(Collectors.toList());
-		//通过规则id获取对应的规则明细
-		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("指标规则明细项为空");
-		}
-
+		for (String ruleId : evaluationRuleIds) {
+			//获取指定部门的规则
+			OrganizationEvaluationRule evaluationRule = organizationEvaluationRuleService.getById(ruleId);
+			if (null == evaluationRule) {
+				throw new CustomException("不存在此单位权重配置");
+			}
 
-		resDTOS.stream().forEach(r -> {
-			ResponsibilityIndicatorInfo info = new ResponsibilityIndicatorInfo();
-			info.setDeptResponsibilityId(oriResponsibility.getId());
-			info.setIndicatorId(r.getId());
-			info.setIndicatorDictionaryId(r.getIndicatorDictionaryID());
-			info.setOptionCode(r.getOptionCode());
-			info.setIsQuantified(r.getIsQuantified());
-			info.setCreateTime(new Date());
-			boolean b2 = responsibilityIndicatorInfoService.saveOrUpdate(info);
-			if (!b2) {
-				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);
+			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("指标规则明细项为空");
+			}
+
+
+			resDTOS.stream().forEach(r -> {
+				ResponsibilityIndicatorInfo info = new ResponsibilityIndicatorInfo();
+				info.setDeptResponsibilityId(oriResponsibility.getId());
+				info.setIndicatorId(r.getId());
+				info.setIndicatorDictionaryId(r.getIndicatorDictionaryID());
+				info.setOptionCode(r.getOptionCode());
+				info.setIsQuantified(r.getIsQuantified());
+				info.setCreateTime(new Date());
+				boolean b2 = responsibilityIndicatorInfoService.saveOrUpdate(info);
+				if (!b2) {
+					throw new CustomException("初始化目标责任书明细失败");
+				}
+			});
+		}
+
 		return true;
 	}
 
@@ -244,12 +198,14 @@ public class DeptResponsibilityServiceImpl extends ServiceImpl<DeptResponsibilit
 	@Override
 	public boolean saveOrUpdate(DeptResponsibility entity) {
 		//获取指定部门的规则
-		List<OrganizationEvaluationRule> list = organizationEvaluationRuleService.listByIsCheck(entity.getOrganizationType(),entity.getCheckCycle(), true, false);
+		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());
+		List<String> organizationNames = list.stream().map(OrganizationEvaluationRule::getOrganizationName).collect(Collectors.toList());
+		List<String> evaluationRuleIds = list.stream().map(OrganizationEvaluationRule::getId).collect(Collectors.toList());
 
 		StringBuilder responsibilityCode = new StringBuilder();
 		responsibilityCode.append(entity.getOrganizationType()).append("_");
@@ -260,27 +216,35 @@ public class DeptResponsibilityServiceImpl extends ServiceImpl<DeptResponsibilit
 		if ("NDKP".equals(entity.getCheckCycle())) {
 			oriList = list("", entity.getCheckCycle(), entity.getYear(), "");
 			responsibilityCode.append(entity.getYear()).append("_");
+			responsibilityCode.append(StringUtils.addZeroForStr(String.valueOf(oriList.size()+1), 4, "l"));
 		}
 		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);
+			List<DeptResponsibility> count = list("", entity.getCheckCycle(), entity.getYear(), "");
 			responsibilityCode.append(entity.getYear()).append("_").append(month).append("_");
+			responsibilityCode.append(StringUtils.addZeroForStr(String.valueOf(count.size()+1), 4, "l"));
 		}
 		if ("YDKP".equals(entity.getCheckCycle())) {
 			oriList = list("", entity.getCheckCycle(), entity.getYear(), entity.getMonth());
 			responsibilityCode.append(entity.getYear()).append("_").append(entity.getMonth()).append("_");
+			List<DeptResponsibility> count = list("", entity.getCheckCycle(), entity.getYear(), "");
+			responsibilityCode.append(StringUtils.addZeroForStr(String.valueOf(count.size()+1), 4, "l"));
 		}
-		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.setResponsibilityCode(responsibilityCode.toString().toLowerCase());
+
+			entity.setOrganizationId(String.join(",", organizationIds));//考评组织ID
+			entity.setOrganizationName(String.join(",", organizationNames));
+			entity.setOrganizationEvaluationRuleId(String.join(",", evaluationRuleIds));
 			entity.setStage("流程未启动");
 			entity.setCreateTime(new Date());
 		} else {
@@ -291,71 +255,15 @@ public class DeptResponsibilityServiceImpl extends ServiceImpl<DeptResponsibilit
 			if (!"流程未启动".equals(update.getStage())) {
 				throw new CustomException("流程已启动不允许修改");
 			}
-			entity.setOrganizationId(organizationIds.toString());//考评组织ID
+			entity.setOrganizationId(String.join(",", organizationIds));//考评组织ID
+			entity.setOrganizationName(String.join(",", organizationNames));
+			entity.setOrganizationEvaluationRuleId(String.join(",", evaluationRuleIds));
 			entity.setUpdateTime(new Date());
 		}
 		boolean b = super.saveOrUpdate(entity);
 		return b;
 	}
 
-	@Transactional
-	@Override
-	public boolean saveOrUpdate2(DeptResponsibility entity) {
-
-		//获取指定部门的规则
-		OrganizationEvaluationRule evaluationRule = organizationEvaluationRuleService.getById(entity.getOrganizationEvaluationRuleId());
-		if (null == evaluationRule) {
-			throw new CustomException("不存在此单位权重配置");
-		}
-
-		StringBuilder responsibilityCode = new StringBuilder();
-		responsibilityCode.append(evaluationRule.getOrganizationType()).append("_");
-		responsibilityCode.append(evaluationRule.getEvaluationCycle()).append("_");
-
-		//判断该是否存在目标责任书
-		List<DeptResponsibility> oriList = new ArrayList<>();
-		if ("NDKP".equals(evaluationRule.getEvaluationCycle())) {
-			oriList = list(evaluationRule.getOrganizationId(), evaluationRule.getEvaluationCycle(), entity.getYear(), "");
-			responsibilityCode.append(entity.getYear()).append("_");
-		}
-		if ("JDKP".equals(evaluationRule.getEvaluationCycle())) {
-			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(evaluationRule.getOrganizationId(), evaluationRule.getEvaluationCycle(), entity.getYear(), month);
-			responsibilityCode.append(entity.getYear()).append("_").append(month).append("_");
-		}
-		if ("YDKP".equals(evaluationRule.getEvaluationCycle())) {
-			oriList = list(evaluationRule.getOrganizationId(), evaluationRule.getEvaluationCycle(), entity.getYear(), entity.getMonth());
-			responsibilityCode.append(entity.getYear()).append("_").append(entity.getMonth()).append("_");
-		}
-		responsibilityCode.append(evaluationRule.getOrganizationId());
-
-
-		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(evaluationRule.getOrganizationId());//考评组织ID
-			entity.setOrganizationName(evaluationRule.getOrganizationName());//考评组织名称
-			entity.setCheckCycle(evaluationRule.getEvaluationCycle());//考评周期
-			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("编辑记录未找到");
-			}
-			entity.setOrganizationId(evaluationRule.getOrganizationId());//考评组织ID
-			entity.setOrganizationName(evaluationRule.getOrganizationName());//考评组织名称
-			entity.setCheckCycle(evaluationRule.getEvaluationCycle());//考评周期
-			entity.setUpdateTime(new Date());
-		}
-		boolean b = super.saveOrUpdate(entity);
-		return b;
-	}
 
 	@Override
 	public List<DeptResponsibility> list(String organizationId, String checkCycle, String year, String month) {