|
|
@@ -52,6 +52,7 @@ public class CoreSafetyIndexCalculateRuleServiceImpl extends ServiceImpl<CoreSaf
|
|
|
private ICoreSafetyIndexCalculateRuleItemService ruleItemService;
|
|
|
@Autowired
|
|
|
private CoreSafetyIndexCalculateRuleItemMapper ruleItemMapper;
|
|
|
+
|
|
|
@Override
|
|
|
public TableDataInfo<CoreSafetyIndexCalculateRulePageVo> selectPage(CoreSafetyIndexCalculateRulePageDto request) {
|
|
|
|
|
|
@@ -61,7 +62,7 @@ public class CoreSafetyIndexCalculateRuleServiceImpl extends ServiceImpl<CoreSaf
|
|
|
if (ObjectUtil.isEmpty(records)) {
|
|
|
return TableDataInfo.build(page);
|
|
|
}
|
|
|
- Map<String, String> map =getCoreSafetyDictMap();
|
|
|
+ Map<String, String> map = getCoreSafetyDictMap();
|
|
|
for (CoreSafetyIndexCalculateRulePageVo record : page.getRecords()) {
|
|
|
//设置组织名称
|
|
|
record.setOrgTypeText(OrgTypeEnum.getName(record.getOrgType()));
|
|
|
@@ -74,7 +75,7 @@ public class CoreSafetyIndexCalculateRuleServiceImpl extends ServiceImpl<CoreSaf
|
|
|
return TableDataInfo.build(page);
|
|
|
}
|
|
|
|
|
|
- private Map<String, String> getCoreSafetyDictMap(){
|
|
|
+ private Map<String, String> getCoreSafetyDictMap() {
|
|
|
List<CoreSafetyDict> dictList = safetyDictService.selectCoreSafetyDictList(null);
|
|
|
return dictList.stream().collect(Collectors.toMap(CoreSafetyDict::getCode, CoreSafetyDict::getName));
|
|
|
}
|
|
|
@@ -88,7 +89,7 @@ public class CoreSafetyIndexCalculateRuleServiceImpl extends ServiceImpl<CoreSaf
|
|
|
@Override
|
|
|
public CoreSafetyIndexCalculateRuleDetailVo selectCoreSafetyIndexCalculateRuleById(Long id) {
|
|
|
CoreSafetyIndexCalculateRule calculateRule = coreSafetyIndexCalculateRuleMapper.selectById(id);
|
|
|
- if (calculateRule==null){
|
|
|
+ if (calculateRule == null) {
|
|
|
throw new SystemException("安全指标配置不存在");
|
|
|
}
|
|
|
CoreSafetyIndexCalculateRuleDetailVo record = new CoreSafetyIndexCalculateRuleDetailVo();
|
|
|
@@ -101,7 +102,7 @@ public class CoreSafetyIndexCalculateRuleServiceImpl extends ServiceImpl<CoreSaf
|
|
|
List<CoreSafetyIndexCalculateRuleItem> list = ruleItemService.list(new LambdaQueryWrapper<CoreSafetyIndexCalculateRuleItem>()
|
|
|
.eq(CoreSafetyIndexCalculateRuleItem::getRuleId, id));
|
|
|
List<CoreSafetyIndexCalculateRuleItemVo> properties = BeanHelper.copyProperties(list, CoreSafetyIndexCalculateRuleItemVo.class);
|
|
|
- properties.forEach(r->{
|
|
|
+ properties.forEach(r -> {
|
|
|
r.setCalculateTypeText(CalculateTypeEnums.getName(r.getCalculateType()));
|
|
|
});
|
|
|
record.setItemList(properties);
|
|
|
@@ -137,7 +138,7 @@ public class CoreSafetyIndexCalculateRuleServiceImpl extends ServiceImpl<CoreSaf
|
|
|
calculateRule.setId(IdWorker.getId());
|
|
|
List<CoreSafetyIndexCalculateRuleItemInsertDto> itemList = coreSafetyIndexCalculateRule.getItemList();
|
|
|
List<CoreSafetyIndexCalculateRuleItem> properties = BeanHelper.copyProperties(itemList, CoreSafetyIndexCalculateRuleItem.class);
|
|
|
- properties.forEach(r->{
|
|
|
+ properties.forEach(r -> {
|
|
|
r.setRuleId(calculateRule.getId());
|
|
|
r.setCreateBy(SecurityUtils.getUserId().toString());
|
|
|
r.setUpdateBy(SecurityUtils.getUserId().toString());
|
|
|
@@ -157,6 +158,9 @@ public class CoreSafetyIndexCalculateRuleServiceImpl extends ServiceImpl<CoreSaf
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public int updateCoreSafetyIndexCalculateRule(CoreSafetyIndexCalculateRuleUpdateDto request) {
|
|
|
+ if (request.getScore() < 0) {
|
|
|
+ throw new RuntimeException("分值不能小于0!");
|
|
|
+ }
|
|
|
CoreSafetyIndexCalculateRule coreSafetyIndexCalculateRule = new CoreSafetyIndexCalculateRule();
|
|
|
BeanUtils.copyProperties(request, coreSafetyIndexCalculateRule);
|
|
|
coreSafetyIndexCalculateRule.setUpdateBy(SecurityUtils.getUserId().toString());
|
|
|
@@ -164,10 +168,16 @@ public class CoreSafetyIndexCalculateRuleServiceImpl extends ServiceImpl<CoreSaf
|
|
|
ruleItemMapper.delete(new LambdaQueryWrapper<CoreSafetyIndexCalculateRuleItem>().eq(CoreSafetyIndexCalculateRuleItem::getRuleId, request.getId()));
|
|
|
List<CoreSafetyIndexCalculateRuleItemUpdateDto> itemList = request.getItemList();
|
|
|
List<CoreSafetyIndexCalculateRuleItem> properties = BeanHelper.copyProperties(itemList, CoreSafetyIndexCalculateRuleItem.class);
|
|
|
- properties.forEach(r->{
|
|
|
+ properties.forEach(r -> {
|
|
|
+ if (ObjectUtil.isNull(r.getIndicatorDays()) || r.getIndicatorDays() < 0) {
|
|
|
+ throw new RuntimeException("连续数不能小于0!");
|
|
|
+ }
|
|
|
+ if (ObjectUtil.isNull(r.getItemValue()) || r.getItemValue() < 0) {
|
|
|
+ throw new RuntimeException("系数不能小于0!");
|
|
|
+ }
|
|
|
r.setUpdateBy(SecurityUtils.getUserId().toString());
|
|
|
r.setUpdateTime(new Date());
|
|
|
- if (r.getId()==null){
|
|
|
+ if (r.getId() == null) {
|
|
|
r.setCreateBy(SecurityUtils.getUserId().toString());
|
|
|
r.setCreateTime(new Date());
|
|
|
}
|