|
|
|
@ -26,8 +26,6 @@ import com.elink.esua.epdc.commons.mybatis.service.impl.BaseServiceImpl; |
|
|
|
import com.elink.esua.epdc.commons.tools.constant.FieldConstant; |
|
|
|
import com.elink.esua.epdc.commons.tools.constant.NumConstant; |
|
|
|
import com.elink.esua.epdc.commons.tools.constant.StrConstant; |
|
|
|
import com.elink.esua.epdc.commons.tools.exception.ErrorCode; |
|
|
|
import com.elink.esua.epdc.commons.tools.exception.RenException; |
|
|
|
import com.elink.esua.epdc.commons.tools.page.PageData; |
|
|
|
import com.elink.esua.epdc.commons.tools.redis.UserDetailRedis; |
|
|
|
import com.elink.esua.epdc.commons.tools.security.user.SecurityUser; |
|
|
|
@ -43,7 +41,6 @@ import com.elink.esua.epdc.dto.ParentAndAllDeptDTO; |
|
|
|
import com.elink.esua.epdc.dto.SysDeptDTO; |
|
|
|
import com.elink.esua.epdc.dto.epdc.form.UserSysDeptInfoFormDTO; |
|
|
|
import com.elink.esua.epdc.dto.epdc.result.UserSysDeptInfoResultDTO; |
|
|
|
import com.elink.esua.epdc.dto.result.ImportExcelErrorResultDTO; |
|
|
|
import com.elink.esua.epdc.dto.result.KpiManualScoreResultDTO; |
|
|
|
import com.elink.esua.epdc.dto.result.KpiManualScoreTemplateResultDTO; |
|
|
|
import com.elink.esua.epdc.entity.KpiManualScoreEntity; |
|
|
|
@ -132,6 +129,36 @@ public class KpiManualScoreServiceImpl extends BaseServiceImpl<KpiManualScoreDao |
|
|
|
return ConvertUtils.sourceToTarget(entityList, KpiManualScoreDTO.class); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Result checkExportTemplate(Map<String, Object> params) { |
|
|
|
//用户所选规则
|
|
|
|
String ruleId = params.get("ruleId").toString(); |
|
|
|
// yyyy-MM
|
|
|
|
String scoreStartMonth = params.get("scoreStartDate").toString(); |
|
|
|
// 考核周期开始月
|
|
|
|
YearMonth scoreStartDateMonth = YearMonth.parse(scoreStartMonth); |
|
|
|
|
|
|
|
// 考核规则
|
|
|
|
KpiRuleEntity kpiRuleEntity = kpiRuleDao.selectById(ruleId); |
|
|
|
|
|
|
|
if (kpiRuleEntity.getKpiCycle().equals(KpiCycleEnum.KPI_CYCLE_MONTH.getValue())) { |
|
|
|
} else if (kpiRuleEntity.getKpiCycle().equals(KpiCycleEnum.KPI_CYCLE_QUARTER.getValue())) { |
|
|
|
int monthValue = scoreStartDateMonth.getMonthValue(); |
|
|
|
// 只有1,4,7,10 月份可以进行季度打分
|
|
|
|
if (monthValue != NumConstant.ONE && monthValue != NumConstant.FOUR |
|
|
|
&& monthValue != NumConstant.SEVEN && monthValue != NumConstant.TEN) { |
|
|
|
return new Result().error("季度打分只能在1/4/7/10月份进行"); |
|
|
|
} |
|
|
|
} else { |
|
|
|
int monthValue = scoreStartDateMonth.getMonthValue(); |
|
|
|
// 只有1月份可以进行年度打分
|
|
|
|
if (monthValue != NumConstant.ONE) { |
|
|
|
return new Result().error("年度打分只能在1月份进行"); |
|
|
|
} |
|
|
|
} |
|
|
|
return new Result(); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @param |
|
|
|
* @return java.util.List<com.elink.esua.epdc.dto.result.KpiManualScoreTemplateResultDTO> |
|
|
|
@ -145,7 +172,7 @@ public class KpiManualScoreServiceImpl extends BaseServiceImpl<KpiManualScoreDao |
|
|
|
//用户所选规则
|
|
|
|
String ruleId = params.get("ruleId").toString(); |
|
|
|
// yyyy-MM
|
|
|
|
String scoreStartMonth = params.get("scoreStartTime").toString(); |
|
|
|
String scoreStartMonth = params.get("scoreStartDate").toString(); |
|
|
|
// 考核周期开始月
|
|
|
|
YearMonth scoreStartDateMonth = YearMonth.parse(scoreStartMonth); |
|
|
|
|
|
|
|
@ -154,26 +181,15 @@ public class KpiManualScoreServiceImpl extends BaseServiceImpl<KpiManualScoreDao |
|
|
|
|
|
|
|
// 考核周期结束日
|
|
|
|
LocalDate scoreEndDate; |
|
|
|
//考核周期赋值
|
|
|
|
// 考核周期赋值
|
|
|
|
String kpiCycleName; |
|
|
|
if (kpiRuleEntity.getKpiCycle().equals(KpiCycleEnum.KPI_CYCLE_MONTH.getValue())) { |
|
|
|
kpiCycleName = KpiCycleEnum.KPI_CYCLE_MONTH.getName(); |
|
|
|
scoreEndDate = scoreStartDateMonth.atEndOfMonth(); |
|
|
|
} else if (kpiRuleEntity.getKpiCycle().equals(KpiCycleEnum.KPI_CYCLE_QUARTER.getValue())) { |
|
|
|
int monthValue = scoreStartDateMonth.getMonthValue(); |
|
|
|
// 只有1,4,7,10 月份可以进行季度打分
|
|
|
|
if (monthValue != NumConstant.ONE && monthValue != NumConstant.FOUR |
|
|
|
&& monthValue != NumConstant.SEVEN && monthValue != NumConstant.TEN) { |
|
|
|
throw new RenException("当前选择的月份无法进行季度考核打分"); |
|
|
|
} |
|
|
|
kpiCycleName = KpiCycleEnum.KPI_CYCLE_QUARTER.getName(); |
|
|
|
scoreEndDate = scoreStartDateMonth.plusMonths(NumConstant.TWO).atEndOfMonth(); |
|
|
|
} else { |
|
|
|
int monthValue = scoreStartDateMonth.getMonthValue(); |
|
|
|
// 只有1月份可以进行年度打分
|
|
|
|
if (monthValue != NumConstant.ONE) { |
|
|
|
throw new RenException("当前选择的月份无法进行年度考核打分"); |
|
|
|
} |
|
|
|
kpiCycleName = KpiCycleEnum.KPI_CYCLE_YEAR.getName(); |
|
|
|
scoreEndDate = scoreStartDateMonth.plusMonths(NumConstant.ELEVEN).atEndOfMonth(); |
|
|
|
} |
|
|
|
@ -202,8 +218,8 @@ public class KpiManualScoreServiceImpl extends BaseServiceImpl<KpiManualScoreDao |
|
|
|
|
|
|
|
kpiManualScoreTemplateResultDTO.setRuleId(kpiRuleEntity.getId()); |
|
|
|
kpiManualScoreTemplateResultDTO.setDeptId(userSysDeptInfoResultDTO.getId().toString()); |
|
|
|
kpiManualScoreTemplateResultDTO.setScoreStartDate(LocalDateUtils.LocalDateToDate(scoreStartDateMonth.atDay(NumConstant.ONE))); |
|
|
|
kpiManualScoreTemplateResultDTO.setScoreEndDate(LocalDateUtils.LocalDateToDate(scoreEndDate)); |
|
|
|
kpiManualScoreTemplateResultDTO.setScoreStartDate(LocalDateUtils.localDateToDate(scoreStartDateMonth.atDay(NumConstant.ONE))); |
|
|
|
kpiManualScoreTemplateResultDTO.setScoreEndDate(LocalDateUtils.localDateToDate(scoreEndDate)); |
|
|
|
kpiManualScoreTemplateResultDTO.setParentDeptIds(userSysDeptInfoResultDTO.getPids()); |
|
|
|
kpiManualScoreTemplateResultDTO.setParentDeptNames(userSysDeptInfoResultDTO.getParentNames()); |
|
|
|
kpiManualScoreTemplateResultDTO.setAllDeptIds(userSysDeptInfoResultDTO.getPids() + StrConstant.COMMA + userSysDeptInfoResultDTO.getId()); |
|
|
|
@ -264,18 +280,9 @@ public class KpiManualScoreServiceImpl extends BaseServiceImpl<KpiManualScoreDao |
|
|
|
return new Result().error("导入内容不能为空"); |
|
|
|
} |
|
|
|
//校验记录数是否一致
|
|
|
|
List<ImportExcelErrorResultDTO> errorRecordList = new ArrayList<>(); |
|
|
|
List<KpiManualScoreTempEntity> tempEntityList = baseDao.selectListKpiManualScoreTemp(SecurityUser.getUserId().toString(), recordList); |
|
|
|
if (CollUtil.isEmpty(tempEntityList) || tempEntityList.size() != recordList.size()) { |
|
|
|
ImportExcelErrorResultDTO excelErrorResultDTO = new ImportExcelErrorResultDTO(); |
|
|
|
excelErrorResultDTO.setErrorLine("0"); |
|
|
|
excelErrorResultDTO.setErrorInfo("导入记录条数与导出模板不一致,请核对"); |
|
|
|
errorRecordList.add(excelErrorResultDTO); |
|
|
|
} |
|
|
|
if (CollUtil.isNotEmpty(errorRecordList)) { |
|
|
|
Result errorResult = new Result(); |
|
|
|
errorResult.setCode(ErrorCode.INTERNAL_SERVER_ERROR); |
|
|
|
return errorResult.ok(errorRecordList); |
|
|
|
return new Result().error("Excel数据异常,请修改后重新导入"); |
|
|
|
} |
|
|
|
List<KpiManualScoreEntity> kpiManualScoreEntityList = ConvertUtils.sourceToTarget(tempEntityList, KpiManualScoreEntity.class); |
|
|
|
//循环插入:如果存在则删除原纪录
|
|
|
|
@ -342,7 +349,7 @@ public class KpiManualScoreServiceImpl extends BaseServiceImpl<KpiManualScoreDao |
|
|
|
KpiManualScoreRuleEntity kpiManualScoreRuleEntity = kpiManualScoreRuleDao.selectOneKpiManualScoreRuleByRuleId(kpiRuleEntity.getId()); |
|
|
|
if (null == kpiManualScoreRuleEntity) { |
|
|
|
return new Result().error("没有找到关联的手动打分项"); |
|
|
|
} else if (null != kpiManualScoreRuleEntity && dto.getScore() > kpiManualScoreRuleEntity.getFullMarks()) { |
|
|
|
} else if (null != kpiManualScoreRuleEntity && dto.getScore().compareTo(kpiManualScoreRuleEntity.getFullMarks()) == NumConstant.ONE) { |
|
|
|
return new Result().error("得分不能高于满分"); |
|
|
|
} |
|
|
|
|
|
|
|
@ -388,7 +395,7 @@ public class KpiManualScoreServiceImpl extends BaseServiceImpl<KpiManualScoreDao |
|
|
|
KpiManualScoreRuleEntity kpiManualScoreRuleEntity = kpiManualScoreRuleDao.selectOneKpiManualScoreRuleByRuleId(dto.getRuleId()); |
|
|
|
if (null == kpiManualScoreRuleEntity) { |
|
|
|
return new Result().error("没有找到关联的手动打分项"); |
|
|
|
} else if (null != kpiManualScoreRuleEntity && dto.getScore() > kpiManualScoreRuleEntity.getFullMarks()) { |
|
|
|
} else if (null != kpiManualScoreRuleEntity && dto.getScore().compareTo(kpiManualScoreRuleEntity.getFullMarks()) == NumConstant.ONE) { |
|
|
|
return new Result().error("得分不能高于满分"); |
|
|
|
} |
|
|
|
updateById(entity); |
|
|
|
|